急!vb中文件的读写。在线等

来源:百度知道 编辑:UC知道 时间:2024/05/24 01:05:43
Private Sub comput_Click()
Type StudType
iNo As Integer
strName AsString * 20
strSex As String * 1
strcode As Integer
End Type
Dim Student As StudType
Student.iNo = Text2.Text
Student.strName = Text1.Text
If Option1.Value = Ture Then
Student.strSex = "1"
Else
Student.strSex = "0"
End If
Open "E:\STUDENT.DATE" For Random As #1 Len = Len(Student)
Put #1, 1, Student
Close #1
End Sub
请帮忙看一下这段程序什么问题,运行后提示无效内部过程。
还是不行啊,运行后提示未找到方法和数据成员,要不把qq给我,那上面说

你的程序问题不少啊!
1、type的定义要写在过程外面,且需要定义成private型
2、strname as string*20那行缺个空格
3 if option1.value=ture写错了,应该是 true
改正后的完整源代码:
Private Type StudType
iNo As Integer
strName As String * 20
strSex As String * 1
strcode As Integer
End Type
Private Sub comput_Click()
Dim Student As StudType
Student.iNo = Text2.Text
Student.strName = Text1.Text
If Option1.Value = True Then
Student.strSex = "1"
Else
Student.strSex = "0"
End If
Open "E:\STUDENT.DATE" For Random As #1 Len = Len(Student)
Put #1, 1, Student
Close #1
End Sub