帮我改改  我总觉得有问题
Type ID
   number As Single
   score As Integer
   name As String * 6
End Type
Dim personl As ID, i%
Private Sub Command1_Click()
 i = 0
 xpath = App.Path & "\ku\score.txt"
 Open xpath For Random As #1 Len = Len(personl)
 personl.number = Val(Text1.Text)
 personl.score = Val(Text2.Text)
 personl.name = Text3.Text
 Put #1, Val(Text4.Text), personl
 i = i + 1
 Close #1
 MsgBox "学生信息已写入!", vbInformation
 Label1.Caption = "总记录数:" + i
 Text1.Text = ""
 Text2.Text = ""
 Text3.Text = ""
 Text4.Text = ""
End Sub
Private Sub Command2_Click()
 xpath = App.Path & "\ku\score.txt"
 Open xpath For Random As #1 Len = Len(personl)
   Get #1, Val(Text4.Text), personl
   Text1.Text = personl.number
   Text2.Text = personl.score
   Text3.Text = personl.name
End Sub

解决方案 »

  1.   


    Private Type ID
      number As Single
      score As Integer
      name As String * 6
    End Type
    Dim personl As ID, i%
    Private Sub Command1_Click()
        xpath = App.Path & "\ku\score.txt"
        Open xpath For Random As #1 Len = Len(personl)
        personl.number = Val(Text1.Text)
        personl.score = Val(Text2.Text)
        personl.name = Text3.Text
        Dim i As Long
        If Val(Text4) = 0 Then
            i = LOF(1) / Len(personl)
            Put #1, i + 1, personl
        Else
            Put #1, Val(Text4.Text), personl
        End If
        Close #1
        MsgBox "学生信息已写入!", vbInformation
        Label1.Caption = "总记录数: " & totalRec
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
    End Sub
    Private Sub Command2_Click()
        xpath = App.Path & "\ku\score.txt"
        Open xpath For Random As #1 Len = Len(personl)
        Get #1, Val(Text4.Text), personl
        Close #1
        Text1.Text = personl.number
        Text2.Text = personl.score
        Text3.Text = personl.name
    End Sub
      

  2.   

    If Val(Text4) = 0 Then
            i = LOF(1) / Len(personl)
            Put #1, i + 1, personl
        Else
            Put #1, Val(Text4.Text), personl
        End If
    是什么意思,有何用?  呵呵我是刚入门 
    Label1.Caption = "总记录数: " & totalRec
    这个标签上没有输出啊
      

  3.   

    If Val(Text4) = 0 Then 
            i = LOF(1) / Len(personl) 
            Put #1, i + 1, personl 
        Else 
            Put #1, Val(Text4.Text), personl 
        End If 
    是什么意思,有何用?  就是当你没有在text4里输入记录位置的时候,记录加在文件尾部。 
    totalRec = LOF(1) / Len(personl)
    Label1.Caption = "总记录数: " & totalRec 
    这个标签上没有输出啊,不好意思红字那句忘写了。
      

  4.   

    分以后一定大方 
        新手刚来 还不这么熟悉
      你给的 
    totalRec = LOF(1) / Len(personl) 
    Label1.Caption = "总记录数: " & totalRec 
     我运行了还是没有输出
    LOF(1) / Len(personl) 是不是提取文件中记录的总数LOF(1)是不是数字从1开始?
      这是我的理解 不知道对不对
    当我TEXT1.TEXT没有写记录好的时候
    弹出窗口  
    实时错误‘52’
    错误文件文件名或号码???
     这个是什么问题