程序运行出错,请求各位高手帮忙啊,感激不尽啊

guanghualee 2003-06-01 12:19:51
Private Type studType
No As Integer
Name As String * 10
Sex As Boolean
Rq As Data
Mz As String * 12
Class As String * 5
End Type
Dim student As studType
Dim Recs As Integer '文件中记录总个数
Dim CurNo As Integer
Dim Op As Integer
Private Sub Form_Load()
Picture2.Visible = False
Open "student.dat" For Random As #1 Len = Len(student)
Recs = LOF(1) / Len(student)
If Recs > 0 Then
CurNo = 1
BEnabled (True)
DispRec
Else
CurNo = 0
BEnabled (False)
TxtEnabled (False)
End If
End Sub
Private Sub Add_Click()
labOp.Caption = "添加记录"
BEnabled (True)
Op = 1
txtNo.Text = ""
txtName.Text = ""
optSex0.Value = True
comMz.Text = ""
txtRq.Text = ""
txtClass.Text = ""
TxtEnabled (True)
Picture1.Visible = False
Picture2.Visible = True
End Sub

Private Sub Bott_Click()
CurNo = Recs
DispRec
End Sub

Private Sub Cancel_Click()
Picture1.Visible = True
Picture2.Visible = False
If Recs = 0 Then
txtNo.Text = ""
txtName.Text = ""
optSex0.Value = True
comMz.Text = ""
txtRq.Text = ""
txtClass.Text = ""
BEnabled (False)
Else
DispRec
End If

End Sub

Private Sub Del_Click()
labOp.Caption = "删除记录"
Op = 2
Picture1.Visible = False
Picture2.Visible = True
End Sub


Private Sub Exit_Click()
Open "student1sdsd.dat" For Binary As #2 Len = Len(student)
For i = 1 To Recs
Get #1, i, student '出错在这儿,编译错误:
Put #2, i, student '不能Get或Put一个对象引用变量或包含
’对象引用的用户定义类型
Close
Next
Kill "student.dat"
Name "student1.dat" As "student.dat"
End
End Sub

Private Sub Nex_Click()
CurNo = CurNo + 1
If CurNo > Recs Then CurNo = Recs
DispRec
End Sub
Private Sub Ok_Click()
Picture2.Visible = False
Picture1.Visible = True
If Op = 1 Then '添加确定
Recs = Recs + 1
CurNo = Recs
WriteRec
ElseIf Op = 2 Then
WriteRec
ElseIf Op = 3 Then
i = CurNo
Do While i < Recs
Get #1, i + 1, student
Put #1, i, student
i = i + 1
Loop
Recs = Recs - 1
student.No = Empty
student.Name = ""
student.Sex = Empty
student.Mz = ""
student.Rq = Empty
student.Class = ""
Put #1, i, student
If Recs = 0 Then
txtNo.Text = ""
txtName.Text = ""
optSex(0).Value = True
comMz.Text = ""
txtRq.Text = ""
txtClass.Text = ""
BEnabled (False)
Else
CurNo = CurNo - 1
DispRec
End If
End If

End Sub

Private Sub Prev_Click()
CurNo = CurNo - 1
If CurNo < 1 Then CurNo = 1
DispRec
End Sub

Private Sub Tp_Click()
CurNo = CurNo - 1
DispRec
End Sub

Private Sub Upd_Click()
labOp.Caption = "修改记录"
Op = 2
TxtEnabled (True)
Picture1.Visible = False
Picture2.Visible = True
End Sub


Private Sub DispRec()
Get #1, CurNo, student
txtNo.Text = student.No
'txtName.Text = student.Name
If student.Sex = True Then
Option1.Value = True
Else
Option2.Value = True
End If
comMz.Text = student.Mz
txtRq.Text = student.Rq
txtClass.Text = student.Class
TxtEnabled (False)
Picture2.Visible = False
End Sub
Private Sub WriteRec()
student.No = Val(txtNo.Text)
student.Name = txtName.Text
If optSex(0) Then
student.Sex = True
Else
student.Sex = False
End If
student.Mz = comMz.Text
If txtRq.Text = "" Then
student.Rq = Empty
Else
student.Rq = txtRq.Text
End If
student.Class = txtClass.Text
Put #1, CurNo, student
End Sub
Private Sub BEnabled(ByVal setvalue As Boolean)
Tp.Enabled = setvalue
Prev.Enabled = setvalue
Nex.Enabled = setvalue
Bott.Enabled = setvalue
Del.Enabled = setvalue
Upd.Enabled = setvalue
End Sub
Private Sub TxtEnabled(ByVal setvalue As Boolean)
txtNo.Enabled = setvalue
txtName.Enabled = setvalue
optSex0.Enabled = setvalue
optSex1.Enabled = setvalue
txtRq.Enabled = setvalue
comMz.Enabled = setvalue
txtClass.Enabled = setvalue
End Sub


大家帮忙看看有什么错误啊,先谢谢了!

...全文
13 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
newste 2003-06-01
晕,连注释都没有怎么有人帮你啊
回复
cdknet 2003-06-01
啥错误提示嘛,这多代码看着都晕
回复
armu80830 2003-06-01
up
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7521

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-06-01 12:19
社区公告
暂无公告