📄 frmviewsnippet.frm
字号:
VERSION 5.00
Begin VB.Form frmViewCD
Caption = "View CD"
ClientHeight = 8790
ClientLeft = 60
ClientTop = 345
ClientWidth = 10170
LinkTopic = "Form1"
ScaleHeight = 8790
ScaleWidth = 10170
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txtCDID
Height = 285
Left = 840
TabIndex = 4
Top = 240
Width = 855
End
Begin VB.TextBox txtTitle
Height = 285
Left = 840
TabIndex = 3
Top = 600
Width = 2415
End
Begin VB.TextBox txtArtist
Height = 7005
Left = 840
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 2
Top = 960
Width = 8655
End
Begin VB.CommandButton cmdView
Caption = "View CD"
Height = 375
Left = 3600
TabIndex = 1
Top = 120
Width = 1095
End
Begin VB.CommandButton cmdDone
Caption = "Done"
Height = 375
Left = 4800
TabIndex = 0
Top = 120
Width = 1095
End
Begin VB.Label Label1
Caption = "CD ID:"
Height = 255
Index = 0
Left = 240
TabIndex = 6
Top = 240
Width = 495
End
Begin VB.Label Label1
Caption = "Title:"
Height = 255
Index = 1
Left = 360
TabIndex = 5
Top = 600
Width = 375
End
End
Attribute VB_Name = "frmViewCD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'##########################
Dim NumRecords As Integer
Dim intFileNum As Integer
Dim lngRecLength As Long
'##########################
Private Type ViewCD
intID As Integer
strTitle As String * 30
strArtist As String * 30
End Type
Private Sub cmdDone_Click()
Unload frmViewCD
End Sub
Private Sub cmdView_Click()
Dim udtCDToView As ViewCD
Dim intCDFile As Integer, lngRecLength As Long
Dim lngTotalRecords As Long, lngCDID As Long
Dim intFileNum As Integer
Dim NumRecords As Long
intFileNum = FreeFile
'Open File
intCDFile = FreeFile
lngRecLength = LenB(udtCDToView)
Open "c:\CdIndex.dat" For Random As #intCDFile Len = lngRecLength
'# of Rec.
If LOF(intFileNum) Mod lngRecLength = 0 Then
NumRecords = (LOF(intCDFile) \ lngRecLength)
Else
NumRecords = (LOF(intCDFile) \ lngRecLength) + 1
End If
lngTotalRecords = NumRecords
'View Rec if Valid
If lngTotalRecords = 0 Then
MsgBox "No CD to View"
cmdView.Enabled = False
Else
lngCDID = txtCDID.Text
If lngCDID > 0 And lngCDID <= lngTotalRecords Then
Get #intCDFile, lngCDID, udtCDToView
txtTitle.Text = udtCDToView.strTitle
txtArtist.Text = udtCDToView.strArtist
Else
Call InitializeForm
MsgBox "Please Enter Valid CD ID"
End If
End If
Close #intCDFile
End Sub
Private Sub Form_Load()
Call InitializeForm
End Sub
Sub InitializeForm()
txtCDID.Text = ""
txtArtist.Text = ""
txtTitle.Text = ""
End Sub
Private Sub txtCDID_Change()
txtArtist.Text = ""
txtTitle.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -