📄 随机文件.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4815
ClientLeft = 60
ClientTop = 450
ClientWidth = 6570
LinkTopic = "Form1"
ScaleHeight = 4815
ScaleWidth = 6570
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "退出"
Height = 465
Left = 5070
TabIndex = 17
Top = 3030
Width = 945
End
Begin VB.CommandButton Command3
Caption = "不及格"
Height = 465
Left = 5070
TabIndex = 16
Top = 2210
Width = 945
End
Begin VB.TextBox Text7
Height = 375
Left = 2370
TabIndex = 15
Top = 4260
Visible = 0 'False
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "查找"
Height = 465
Left = 5070
TabIndex = 13
Top = 1410
Width = 945
End
Begin VB.CommandButton Command1
Caption = "写入"
Height = 465
Left = 5070
TabIndex = 12
Top = 570
Width = 945
End
Begin VB.TextBox Text6
Height = 375
Left = 2370
TabIndex = 5
Top = 3600
Width = 1695
End
Begin VB.TextBox Text5
Height = 375
Left = 2370
TabIndex = 4
Top = 2940
Width = 1695
End
Begin VB.TextBox Text4
Height = 375
Left = 2370
TabIndex = 3
Top = 2280
Width = 1695
End
Begin VB.TextBox Text3
Height = 375
Left = 2370
TabIndex = 2
Top = 1620
Width = 1695
End
Begin VB.TextBox Text2
Height = 375
Left = 2370
TabIndex = 1
Top = 960
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Left = 2370
TabIndex = 0
Top = 300
Width = 1695
End
Begin VB.Label Label7
Alignment = 2 'Center
Caption = "平均成绩:"
Height = 315
Left = 1290
TabIndex = 14
Top = 4290
Visible = 0 'False
Width = 1065
End
Begin VB.Label Label6
Alignment = 2 'Center
Caption = "计算机:"
Height = 315
Left = 1290
TabIndex = 11
Top = 3630
Width = 1065
End
Begin VB.Label Label5
Alignment = 2 'Center
Caption = "外语:"
Height = 315
Left = 1290
TabIndex = 10
Top = 2985
Width = 1065
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "数学:"
Height = 315
Left = 1290
TabIndex = 9
Top = 2325
Width = 1065
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "性别:"
Height = 315
Left = 1290
TabIndex = 8
Top = 1665
Width = 1065
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "姓名:"
Height = 315
Left = 1290
TabIndex = 7
Top = 1020
Width = 1065
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "学号:"
Height = 315
Left = 1290
TabIndex = 6
Top = 360
Width = 1065
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Type students
id As String * 3
name As String * 10
sex As String * 2
math As Single
english As Single
computer As Single
enter As String * 2
End Type
Private Sub Command1_Click()
Dim stu As students
Dim i As Integer
If Text1 = "" Or Text2 = "" Or Text3 = "" Then
MsgBox "输入不能为空", vbCritical, "出错了"
Exit Sub
Else
stu.id = Text1.text
stu.name = Text2.text
stu.sex = Text3.text
stu.math = Text4.text
stu.english = Text5.text
stu.computer = Text6.text
stu.enter = Chr(13) & Chr(10)
Open App.Path & "\stus.txt" For Random As #1 Len = Len(stu)
i = LOF(1) / Len(stu)
Put #1, i + 1, stu
Close #1
Text1.text = ""
Text2.text = ""
Text3.text = ""
Text4.text = ""
Text5.text = ""
Text6.text = ""
End If
Text7.Visible = False
Label7.Visible = False
End Sub
Private Sub Command2_Click()
Dim str As String
Dim stu As students
Dim f As Integer
Dim count As Integer
str = InputBox("请输入要查找的名字:", "查找")
count = Len(str)
Open App.Path & "\stus.txt" For Random As #1 Len = Len(stu)
f = LOF(1) / Len(stu)
For i = 1 To f
Get #1, i, stu
If i = f And Left(stu.name, count) <> str Then
MsgBox "没有找到记录", vbInformation, "结果"
ElseIf Left(stu.name, count) = str Then
Text1.text = stu.id
Text2.text = stu.name
Text3.text = stu.sex
Text4.text = stu.math
Text5.text = stu.english
Text6.text = stu.computer
Text7.Visible = True
Label7.Visible = True
Text7.text = CSng(CSng(Text4.text) + CSng(Text5.text) + CSng(Text6.text)) / 3
Exit For
End If
Next i
Close #1
End Sub
Private Sub Command3_Click()
Dim stu As students
Dim i As Integer
Dim all As Single
Dim name As String
Dim s As String
Dim text As String
Open App.Path & "\nos.txt" For Output As #2
Print #2,
Close #2
Open App.Path & "\stus.txt" For Random As #1 Len = Len(stu)
f = LOF(1) / Len(stu)
For i = 1 To f
Get #1, i, stu
all = CSng(CSng(stu.math) + CSng(stu.computer) + CSng(stu.english)) / 3
If all < 60 Then
name = stu.name
Open App.Path & "\nos.txt" For Append As #2
Print #2, name, all
text = text + name & all & Chr(13) & Chr(10)
Close #2
End If
Next i
Close #1
'Open App.Path & "\nos.txt" For Input As #2
'Do While Not EOF(2)
'Line Input #2, s
'text = text + s + Chr(13) + Chr(10)
'Loop
'Close #2
MsgBox text, , "不及格报表"
'Open App.Path & "\nos.txt" For Output As #2
'Print #2,
'Close #2
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -