我有个学生成绩管理软件,别的都行就是查询功能无法实现,老是提示没有该记录。
各位高人帮忙看一下。Private Sub Command1_Click()
Dim h As Integer
Dim n As Integer
Dim F As Integer
Dim Comp1 As String
Dim Comp2 As String
Text1.Text = "学号" + "      " + "姓名" + "      " + "高数" + "      " + "英语" + "      " + "物理" + "      " + "c语言" + "    " + "计算机文化基础" + "    " + "平均分" + Chr(13) + Chr(10)
F = 0
h = 1Open "cj.dat" For Random As #1 Len = Len(recordvar)
recordnumer = LOF(1) / Len(recordvar)
For n = 1 To recordnumer
            Get #1, n, recordvar
            
Comp1 = Trim(textfindNum.Text)
temptext.Text = recordvar.stnum
Comp2 = Trim(temptext.Text)
           
            
            
            If StrComp(Comp1, Comp2) = 0 Then
                h = n
                F = F + 1
              
Get #1, h, recordvar
With recordvarText1.Text = Text1.Text + recordvar.stnum + recordvar.stname + "      " + Trim(recordvar.gaoshu) + "         " + Trim(recordvar.yingyu) + "         " + Trim(recordvar.wuli) + "         " + Trim(recordvar.cyuyan) + "          " + Trim(recordvar.jisuanji) + "               " + Trim(recordvar.average) + Chr(13) + Chr(10)
End With
End If
Next n
Close #1Label1.Caption = "一共找到" + Str(F) + "条记录"
If F = 0 ThenMsgBox "没有该记录", vbInformation, "提示"
End If
End SubPrivate Sub command2_Click()
Unload Me
Form2.Show
Form10.Command4.Visible = False
Form10.Command2.Visible = True
End SubPrivate Sub Command3_Click()Dim h As Integer
Dim n As Integer
Dim F As Integer
Dim Comp1 As String
Dim Comp2 As String
Text1.Text = "学号" + "     " + "姓名" + "      " + "高数" + "      " + "英语" + "      " + "物理" + "      " + "c语言" + "    " + "计算机文化基础" + "    " + "平均分" + Chr(13) + Chr(10)
F = 0
h = 1
Open "cj.dat" For Random As #1 Len = Len(recordvar)
recordnumer = LOF(1) / Len(recordvar)
For n = 1 To recordnumer
            Get #1, n, recordvar
            
Comp1 = Trim(textfindname.Text)
temptext.Text = recordvar.stname
Comp2 = Trim(temptext.Text)
           
            
            
            If StrComp(Comp1, Comp2) = 0 Then
                h = n
                F = F + 1
              
Get #1, h, recordvar
With recordvarText1.Text = "学号" + "      " + "姓名" + "      " + "高数" + "      " + "英语" + "      " + "物理" + "      " + "c语言" + "    " + "计算机文化基础" + "    " + "平均分" + Chr(13) + Chr(10)
End With
                
   Text1.Text = Text1.Text + recordvar.stnum + recordvar.stname + "      " + Trim(recordvar.gaoshu) + "         " + Trim(recordvar.yingyu) + "         " + Trim(recordvar.wuli) + "         " + Trim(recordvar.cyuyan) + "          " + Trim(recordvar.jisuanji) + "               " + Trim(recordvar.average) + Chr(13) + Chr(10)
            End If
Next n
Close #1Label1.Caption = "一共找到" + Str(F) + "条记录"
If F = 1 ThenMsgBox "没有该记录", vbInformation, "提示"
End If
End SubPrivate Sub Command4_Click()
Unload Me
Form2.Show
Form2.修改.Visible = False
Form2.添加.Visible = False
Form2.删除.Visible = False
Form10.Command2.Visible = False
End Sub