If Text2.Text <> \
If Text3.Text = Text2.Text Then rs.LockType = adLockOptimistic rs.CursorType = adOpenKeyset
rs.Open \超级用户\ rs.AddNew
rs.Fields(\ rs.Fields(\ rs.Update rs.Close Me.Hide upok = True MsgBox \添加成功\ Else
MsgBox \密码错误,请重新输入!\ End If Else
MsgBox \密码不能为空,请输入密码!\ End If Else
MsgBox \用户名不能为空\ End If ' End If Exit Sub errh:
MsgBox Err.Description End Sub
2、修改密码窗口:
设计效果如下:
15
其代码如下:
Private Sub Command1_Click() On Error GoTo errh
Dim rs As New Recordset 'If Not addnewstate Then If Text1.Text <> \ If Text2.Text <> \ If Text3.Text <> \
If Text3.Text = Text4.Text Then
Set rs = cn.Execute(\超级用户 \ If rs.EOF Then rs.Close Exit Sub End If rs.Close
rs.LockType = adLockOptimistic rs.CursorType = adOpenKeyset
rs.Open \超级用户\ rs.Find (\ If rs.Fields(\ rs.Update \ rs.Close Me.Hide upok = True MsgBox \修改成功!\
16
Else
MsgBox \错误的的旧密码\ rs.Close End If Else
MsgBox \密码错误,请重新输入\ End If Else
MsgBox \密码不能为空\ End If Else
MsgBox \密码不能为空\ End If Else
MsgBox \用户名不能为空\End If Exit Sub errh:
MsgBox Err.Description End Sub
Private Sub Command2_Click() Me.Hide
upok = False End Sub
Private Sub Form_Load() MakeCenter frmPass End Sub
4.4查看和修改界面
17
该模块可以实现创建、修改、删除和查看学生基本信息等功能。该窗体效果如下图。
该窗体的代码如下: Option Explicit
Dim rs As ADODB.Recordset Dim rs1 As ADODB.Recordset Dim txtSQL As String Dim MsgText As String Dim mybookmark As Variant Dim mcclean As Boolean 'Private Sub Combo1_Change() 'Combo1.AddItem \男\'Combo1.AddItem \女\'End Sub
Private Sub Command1_Click() On Error GoTo errh If Combo4.Text <> \ If Combo2.Text <> \
18
If Text1.Text <> \ If Text13.Text <> \ If Combo3.Text <> \ If checkclass Then If checkcourse Then If match = True Then Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(\课程号\
Adodc1.Recordset.Fields(\学号\ Adodc1.Recordset.Fields(\成绩\
Adodc1.Recordset.Fields(\课程名称\
Adodc1.Recordset.Fields(\备注\ Adodc1.Recordset.Update MsgBox \添加成功!\ Combo4.Text = \ Combo2.Text = \ Combo3.Text = \ 'Text2.Text = \ Text13.Text = \ Else
MsgBox \成绩和备注不匹配,请核对!\ End If Else
MsgBox \没有这个课程,不能添加!\ Combo3.Text = \ Text13.Text = \ Combo4.Text = \ Combo2.Text = \ Combo4.SetFocus End If
19