随机文件读写问题
我自己写的源代码::Private Type Student
Student_ID As String * 8
Student_Name As String * 6
Student_score1 As Integer
Student_score2 As Integer
Student_score3 As Integer
End Type
Private stu As Student
Dim FileName As String
Dim intCurRecord As Integer
Dim intLastRecord As Integer
Dim intCount As Integer
Dim intFileNum As Integer
Private Sub Cmd_Exit_Click()
End
End Sub
Private Sub Cmd_Next_Click()
If intCurRecord < intLastRecord Then
intCurRecord = intCurRecord + 1
Else
If MsgBox("已经是最后一条记录了,是否回到首记录?", vbYesNo + vbQuestion) = vbYes Then
intCurRecord = 1
ReadStudentInfo
End If
End If
Get #intFileNum, intCurRecord, stu
ReadStudentInfo
Close
End Sub
Private Sub Cmd_Previde_Click()
If intCurRecord > 1 Then
intCurRecord = intCurRecord - 1
Else
MsgBox "已经到了第一条记录了!!!", vbInformation
End If
Get #intFileNum, intCurRecord, stu
ReadStudentInfo
Close
End Sub
Private Sub ReadStudentInfo()
Text1.Text = stu.Student_ID
Text2.Text = stu.Student_Name
Text3 = stu.Student_score1
Text4 = stu.Student_score2
Text5 = stu.Student_score3
End Sub
Private Sub Form_Load()
intFileNum = FreeFile()
strFileName = App.Path & "\学生成绩信息.txt"
Open strFileName For Random As #intFileNum Len = Len(stu)
intLastRecord = LOF(1) / Len(stu)
intCurRecord = 1
If LOF(intFileNum) <> 0 Then
Get #intFileNum, intCurRecord, stu
ReadStudentInfo
End If
End Sub
学生成绩单.zip
(1.8 KB)
实现不了额~~望高手帮忙啊