VB中实时错误62,输入超出文件尾,每次就是在Input #1,那,但是先都能运行的,后面测试时就出了这个问题!

代码如下:Private Sub Command3_Click() '添加记录
Dim j As Integer
ReDim stu(1 To counter + 1) As student
msg0$ = "添加"
msg1$ = InputBox("请输入所要添加的学号:", msg0$)
msg2$ = InputBox("请输入所要添加的姓名:", msg0$)
msg3$ = InputBox("请输入所要添加记录照片的存储路径:", msg0$)
Open "H:\哈哈\程序相关\资料.dat" For Input As #1
For i = 1 To counter
Input #1, stu(i).card, stu(i).name, stu(i).sex, stu(i).mz, stu(i).zzmm, stu(i).qs, stu(i).bj, stu(i).phone, stu(i).jg, stu(i).gkcj, stu(i).gfs, stu(i).drzw, stu(i).byzx, stu(i).jtzz, stu(i).lxr, stu(i).yb, stu(i).lxdh, stu(i).ksh, stu(i).sfzh, stu(i).bz
Next i
Close #1
For i = 1 To counter
If stu(i).name = msg1$ Then
MsgBox ("学号重复,添加失败,请检验。")
j = 1
Exit Sub
End If
If msg1$ = "" Then
MsgBox ("学号不能为空,添加失败,请检验。")
j = 1
Exit Sub
End If
Next i
msg$ = "H:\哈哈\程序相关\图片\" + msg1$ + ".ico"
FileCopy msg3$, msg$
counter = counter + 1
Kill "H:\哈哈\程序相关\counter.dat"
Open "H:\哈哈\程序相关\counter.dat" For Output As #1
Write #1, counter
Close #1
不懂你问的哪个数组,怎么改,我有代码在这,请高手改下,具体点,说得太笼统我不明白啊!!!下面是模块的代码:
Public counter As Integer '记录的个数
Public Type student
card As String
name As String
sex As String
mz As String
zzmm As String
qs As String
bj As String
phone As String
jg As String
gkcj As String
gfs As String
drzw As String
byzx As String
jtzz As String
lxr As String
yb As String
lxdh As String
ksh As String
sfzh As String
bz As String
End Type
Public fform As Integer
Public flag As Integer 'form2、form4的enabled属性的判别
Public cx As Integer '查询方式的开关变量

将接收文件内容的变量定义为字节型 视滦网追问

不会0.0,能详细点?怎么改啊!!,counter 也是定义的integer,

追答

那个数组是什么类型

温馨提示:答案为网友推荐,仅供参考
相似回答