当前位置:编程学习 > VB >>

问一个很菜鸟的问题

我依照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
--------------------编程问答-------------------- For I = 3 To 5
a(I) =a(I)+ Val(Text1(I).Text)
Next
--------------------编程问答-------------------- 恩,谢谢~~ --------------------编程问答-------------------- 天才,7个多月了,哈 --------------------编程问答-------------------- 我晕,迟来的谢谢..........
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,