📄 practice12_4.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form1
Caption = "按指定的记录号读取随机文件"
ClientHeight = 4305
ClientLeft = 60
ClientTop = 345
ClientWidth = 5685
LinkTopic = "Form1"
ScaleHeight = 4305
ScaleWidth = 5685
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4560
Top = 120
_ExtentX = 847
_ExtentY = 847
_Version = 393216
Flags = 259
End
Begin VB.Frame Frame1
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3255
Left = 360
TabIndex = 2
Top = 720
Width = 4815
Begin VB.TextBox Text5
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1440
TabIndex = 10
Top = 2400
Width = 2895
End
Begin VB.TextBox Text4
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1440
TabIndex = 9
Top = 1680
Width = 2895
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1440
TabIndex = 8
Top = 960
Width = 2895
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1440
TabIndex = 7
Top = 360
Width = 2895
End
Begin VB.Label Label5
Caption = "地址:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 480
TabIndex = 6
Top = 2520
Width = 615
End
Begin VB.Label Label4
Caption = "电话:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 480
TabIndex = 5
Top = 1800
Width = 615
End
Begin VB.Label Label3
Caption = "姓名:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 480
TabIndex = 4
Top = 1080
Width = 615
End
Begin VB.Label Label2
Caption = "序号:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 480
TabIndex = 3
Top = 480
Width = 615
End
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 465
Left = 2280
TabIndex = 1
Top = 120
Width = 1935
End
Begin VB.Label Label1
Caption = "请输入姓名:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 0
Top = 240
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Type TelRec
no As String * 5
nam As String * 10
Tel As String * 10
Addr As String * 20
End Type
Dim MyAddr As TelRec
Dim TotalRecno
Private Sub Form_Load()
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Random As #1 Len = Len(MyAddr)
TotalRecno = LOF(1) / Len(MyAddr) '求记录数
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
recno = 1
FindName = Text1.Text
If KeyCode = 13 Then
Do While recno <= TotalRecno
Get #1, recno, MyAddr
If Trim(MyAddr.nam) = Trim(FindName) Then
Text2.Text = MyAddr.no
Text3.Text = MyAddr.nam
Text4.Text = MyAddr.Tel
Text5.Text = MyAddr.Addr
Exit Sub
End If
recno = recno + 1
Loop
MsgBox "指定的姓名没有找到"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -