📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 4140
ClientLeft = 60
ClientTop = 345
ClientWidth = 5325
LinkTopic = "Form2"
ScaleHeight = 4140
ScaleWidth = 5325
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "显示"
Height = 615
Left = 3480
TabIndex = 8
Top = 480
Width = 735
End
Begin VB.ListBox List1
Height = 1500
Left = 240
TabIndex = 7
Top = 2160
Width = 4815
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 375
Left = 3720
TabIndex = 6
Top = 1560
Width = 855
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 375
Left = 1920
TabIndex = 5
Top = 1560
Width = 855
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 240
TabIndex = 4
Top = 1560
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Left = 1560
TabIndex = 3
Top = 840
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Left = 1560
TabIndex = 1
Top = 240
Width = 1215
End
Begin VB.Label Label2
Caption = "成绩"
Height = 375
Left = 360
TabIndex = 2
Top = 840
Width = 855
End
Begin VB.Label Label1
Caption = "姓名"
Height = 375
Left = 360
TabIndex = 0
Top = 240
Width = 855
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim stud1 As stud
Private Sub Command1_Click()
Dim fno, i As Integer
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "请输入信息", "提示信息"
Exit Sub
End If
fno = FreeFile
stud1.name = Form2.Text1.Text
stud1.score = Form2.Text2.Text
Open "c:\score.dat" For Random As #fno Len = Len(stud1)
Put #fno, LOF(1) / Len(stud1) + 1, stud1
Close #fno
List1.AddItem Text1.Text + Space(10) + Text2.Text
List1.Selected(List1.ListCount - 1) = True
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Dim d, i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
d = i + 1
i = List1.ListIndex + 10
End If
Next i
Open "c:\score.dat" For Random As #1 Len = Len(stud1)
Open "c:\score.temp" For Random As #2 Len = Len(stud1)
For i = 1 To LOF(1) / Len(stud1)
If i <> d Then
Get #1, i, stud1
Put #2, , stud1
End If
Next i
Close #2
Close #1
Kill "c:\score.dat"
Name "c:\score.temp" As "c:\score.dat"
List1.RemoveItem d - 1
End Sub
Private Sub Command3_Click()
Dim v As Integer
v = MsgBox("确实要退出吗?", 256 + 33, "提示信息")
If v = 1 Then End
End Sub
Private Sub command4_click()
Dim fno, i As Integer
Dim infom As String
List1.Clear
Text1.Text = ""
Text2.Text = ""
fno = FreeFile
Open "c:\score.dat" For Random As #fno Len = Len(stud1)
If LOF(fno) = 0 Then
MsgBox "当前成绩文档为空!", "提示信息"
Close #fno
Exit Sub
Else
For i = 1 To LOF(1) / Len(stud1)
Get #fno, i, stud1
If i = 1 Then
Text1.Text = stud1.name
Text2.Text = stud1.score
End If
infom = Trim(stud1.name) + Space(10) + Trim(Str(stud1.score))
List1.AddItem infom
Next i
End If
Close #fno
End Sub
Private Sub List1_dblClick()
Dim fno, i As Integer
Dim infom As String
fno = FreeFile
Open "c:\score.dat" For Random As #fno Len = Len(stud1)
If LOF(fno) = 0 Then
Text1.Text = ""
Text2.Text = ""
Exit Sub
Else
Get #fno, List1.ListIndex + 1, stud1
Text1.Text = stud1.name
Text2.Text = stud1.score
End If
Close #fno
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -