📄 pexam12_7.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 = 2400
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 = 2175
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Type StudRec
No As String * 6
Name As String * 8
Math As Integer
English As Integer
End Type
Dim StudTab As StudRec
Private Sub Form_Load()
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Random As #1 Len = Len(StudTab)
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
recno = Val(Text1.Text)
If KeyCode = 13 Then
' 以下LOF函数返回Open 语句打开的文件的大小
If recno > LOF(1) / Len(StudTab) Or recno <= 0 Then
MsgBox "记录号超出范围"
Text1.SetFocus: Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Exit Sub
End If
Get #1, recno, StudTab
Text2.Text = StudTab.No
Text3.Text = StudTab.Name
Text4.Text = StudTab.Math
Text5.Text = StudTab.English
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -