我是一VB初学者,编写一个文件操作练习在编译程序时,出现不少错误如下:如:
编译错误
过程声明与同名事件或过程的描述不匹配
请问怎么办 请求高手帮忙!在一个
name:huaching
pass:Ligh0911大家多多帮忙啊!
程序代码:
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 Exit_Click()
Open "student1.dat" For Random As #2 Len = Len(student)
For i = 1 To Recs
Get #1, i, student
Put #2, i, student
Next
Close
Kill "student.dat"
Name "student1.dat" As "student.dat"
End Sub 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 SubPrivate Sub Tp_Click()
CurNo = 1
DispRec
End SubPrivate Sub Prev_Click()
CurNo = CurNo - 1
If CurNo < 1 Then CurNo = 1
DispRec
End SubPrivate Sub Nex_Click()
CurNo = CurNo + 1
If CurNo > Recs Then CurNo = Recs
DispRec
End SubPrivate Sub Bott_Click()
CurNo = Recs
DispRec
End SubPrivate Sub Add_Click()
labOp.Caption = "添加记录"
BEnabled (True)
Op = 1
txtNo.Text = ""
txtName.Text = ""
optSex(0).Value = True
comMz .Text = ""
txtRq.Text = ""
txtClass.Text = ""
TxtEnabled (True)
Picture1.Visible = False
Picture2.Visible = True
End SubPrivate Sub Upd_click()
labOp.Caption = "修改记录"
Op = 2
TxtEnabled (True)
Picture1.Visible = False
Picture2.Visible = True
End SubPrivate Sub Del_Click()
labOp.Caption = "删除记录"
Op = 3
Picture1.Visible = False
Picture2.Visible = True
End SubPrivate Sub Ok_click()
Picture1.Visible = True
Picture2.Visible = False
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 SubPrivate Sub Cancel_Click()
Picture1.Visible = True
Picture2.Visible = False
If Recs = 0 Then
txtNo.Text = ""
txtName.Text = ""
optSex(0).Value = True
comMz.Text = ""
txtRq.Text = ""
txtClass.Text = ""
BEnabled (False)
Else
DispRec
End If
End SubPrivate Sub DispRec()
Get #1, CurNo, student
txtNo.Text = student.No
txtName.Text = student.Name
If student.Sex = True Then
optSex(0).Value = True
Else
optSex(1).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
optSex(0).Enabled = setvalue
optSex(1).Enabled = setvalue
txtRq.Enabled = setvalue
comMz.Enabled = setvalue
txtClass.Enabled = setvalue
End Sub
编译错误
过程声明与同名事件或过程的描述不匹配
请问怎么办 请求高手帮忙!在一个
name:huaching
pass:Ligh0911大家多多帮忙啊!
程序代码:
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 Exit_Click()
Open "student1.dat" For Random As #2 Len = Len(student)
For i = 1 To Recs
Get #1, i, student
Put #2, i, student
Next
Close
Kill "student.dat"
Name "student1.dat" As "student.dat"
End Sub 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 SubPrivate Sub Tp_Click()
CurNo = 1
DispRec
End SubPrivate Sub Prev_Click()
CurNo = CurNo - 1
If CurNo < 1 Then CurNo = 1
DispRec
End SubPrivate Sub Nex_Click()
CurNo = CurNo + 1
If CurNo > Recs Then CurNo = Recs
DispRec
End SubPrivate Sub Bott_Click()
CurNo = Recs
DispRec
End SubPrivate Sub Add_Click()
labOp.Caption = "添加记录"
BEnabled (True)
Op = 1
txtNo.Text = ""
txtName.Text = ""
optSex(0).Value = True
comMz .Text = ""
txtRq.Text = ""
txtClass.Text = ""
TxtEnabled (True)
Picture1.Visible = False
Picture2.Visible = True
End SubPrivate Sub Upd_click()
labOp.Caption = "修改记录"
Op = 2
TxtEnabled (True)
Picture1.Visible = False
Picture2.Visible = True
End SubPrivate Sub Del_Click()
labOp.Caption = "删除记录"
Op = 3
Picture1.Visible = False
Picture2.Visible = True
End SubPrivate Sub Ok_click()
Picture1.Visible = True
Picture2.Visible = False
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 SubPrivate Sub Cancel_Click()
Picture1.Visible = True
Picture2.Visible = False
If Recs = 0 Then
txtNo.Text = ""
txtName.Text = ""
optSex(0).Value = True
comMz.Text = ""
txtRq.Text = ""
txtClass.Text = ""
BEnabled (False)
Else
DispRec
End If
End SubPrivate Sub DispRec()
Get #1, CurNo, student
txtNo.Text = student.No
txtName.Text = student.Name
If student.Sex = True Then
optSex(0).Value = True
Else
optSex(1).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
optSex(0).Enabled = setvalue
optSex(1).Enabled = setvalue
txtRq.Enabled = setvalue
comMz.Enabled = setvalue
txtClass.Enabled = setvalue
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货