菜鸟求救!!在线等待指教

toalice 2011-02-12 09:09:05
我依照VB书本上的一个简单的学生成绩管理程序代码,照着样子做出来,运行后,发现在文本框中输入了学号、姓名等,文本框里的数据全都消失了,请问怎么解决啊!急
我把代码贴上来了,请指教!
Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Adodc1.Caption = "记录:" & (Adodc1.Recordset.AbsolutePosition) & "/" & Adodc1.Recordset.RecordCount
End Sub

Private Sub Check1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text1(3).SetFocus
End If

End Sub

Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
If Command1(0).Caption = "添加" Then
Command1(0).Caption = "确定"
Command1(1).Caption = "取消"
Adodc1.Recordset.AddNew
aa (False)
Else
Command1(0).Caption = "添加"
Command1(1).Caption = "编辑"
Adodc1.Recordset.UpdateBatch adAffectAllChapters
aa (True)
End If
Case 1
If Command1(1).Caption = "编辑" Then
Command1(0).Caption = "确定"
Command1(1).Caption = "取消"
aa (False)
Else
Command1(0).Caption = "添加"
Command1(0).Caption = "确定"
Command1(1).Caption = "取消"
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
aa (True)
End If
Case 2
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
End Select
Text1(0).SetFocus




End Sub

Private Sub aa(I As Boolean)
Dim otxt As TextBox
For Each otxt In Text1
otxt.Locked = 1
Next
Command1(2).Visible = 1
Adodc1.Enabled = 1

End Sub

Private Sub Form_Load()

End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
Select Case Index
Case 0, 1, 3, 4, 5
Text1(Index + 1).SetFocus
Case 2
Check1.SetFocus
Case 6
Text1(0).SetFocus
End Select
End If
End Sub

Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Dim a(3 To 5) As Single
Select Case Index
Case 0 To 2
If Text1(Index).Text = "" Then
MsgBox "it must have data!"
Cancel = False
Text1(Index).SetFocus
End If
Case 3 To 5
For I = 3 To 5
a(I) = Val(Text1(I).Text)
Next
Text1(6).Text = a(3) + a(4) + a(5)
End Select
End Sub
...全文
92 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
王二.麻子 2011-03-05
  • 打赏
  • 举报
回复
F8,单步执行慢慢看吧
晴天娃娃 2011-03-05
  • 打赏
  • 举报
回复
学生管理用VB做是不错,但是建议用VF做。。。。。。。。。。。。
  • 打赏
  • 举报
回复
重复发帖之一
dbcontrols 2011-02-13
  • 打赏
  • 举报
回复
For I = 3 To 5
a(I) =a(I)+ Val(Text1(I).Text)
Next

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧