主题:求助 麻烦解释一下这两段vb程序~谢谢
Option Explicit
'Public k As Boolean
Public LoginSucceeded As Boolean
Private Const mcPassWord As String = "111"
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Unload Me
End
End Sub
Private Sub cmdOK_Click()
'检查正确的密码
If txtPassword = mcPassWord Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
LoginSucceeded = True
Unload Me
MDIMain.Show
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
'k = False
End Sub
Private Sub txtPassword_Click()
If txtPassword.Text = "在这里输入密码" Then
txtPassword.Text = ""
txtPassword.PasswordChar = "*"
End If
End Sub
Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdOK_Click
End If
End Sub
Option Explicit
Private Sub Command1_Click()
Dim rst As Recordset
Set rst = New Recordset
rst.ActiveConnection = pCN
rst.Source = "select * from 系统设置"
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.LockType = adLockBatchOptimistic
rst.Open
If Option1.Value Then
rst![考试套号] = Combo1.ItemData(Combo1.ListIndex)
Else
rst![考试套号] = 0
End If
rst.UpdateBatch
Set rst = Nothing
MsgBox "题库设置成功了!", vbInformation
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
frmSetup.Height = 0
Call InitCmb
End Sub
''初始化套号
Private Sub InitCmb()
Dim i As Integer
Dim rst As Recordset
Set rst = New Recordset
rst.ActiveConnection = pCN
rst.Source = "select * from 套号"
rst.LockType = adLockBatchOptimistic
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.Open
Combo1.Clear
For i = 1 To rst.RecordCount
Combo1.AddItem rst![套号名称]
Combo1.ItemData(Combo1.ListCount - 1) = rst![ID]
rst.MoveNext
Next i
Me.Combo1.ListIndex = 0
Set rst = Nothing
End Sub
Private Sub Option1_Click()
Combo1.Enabled = True
End Sub
Private Sub Option2_Click()
Combo1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If frmSetup.Height < 3555 Then
frmSetup.Height = frmSetup.Height + 100
End If
End Sub
'Public k As Boolean
Public LoginSucceeded As Boolean
Private Const mcPassWord As String = "111"
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Unload Me
End
End Sub
Private Sub cmdOK_Click()
'检查正确的密码
If txtPassword = mcPassWord Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
LoginSucceeded = True
Unload Me
MDIMain.Show
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
'k = False
End Sub
Private Sub txtPassword_Click()
If txtPassword.Text = "在这里输入密码" Then
txtPassword.Text = ""
txtPassword.PasswordChar = "*"
End If
End Sub
Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdOK_Click
End If
End Sub
Option Explicit
Private Sub Command1_Click()
Dim rst As Recordset
Set rst = New Recordset
rst.ActiveConnection = pCN
rst.Source = "select * from 系统设置"
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.LockType = adLockBatchOptimistic
rst.Open
If Option1.Value Then
rst![考试套号] = Combo1.ItemData(Combo1.ListIndex)
Else
rst![考试套号] = 0
End If
rst.UpdateBatch
Set rst = Nothing
MsgBox "题库设置成功了!", vbInformation
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
frmSetup.Height = 0
Call InitCmb
End Sub
''初始化套号
Private Sub InitCmb()
Dim i As Integer
Dim rst As Recordset
Set rst = New Recordset
rst.ActiveConnection = pCN
rst.Source = "select * from 套号"
rst.LockType = adLockBatchOptimistic
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.Open
Combo1.Clear
For i = 1 To rst.RecordCount
Combo1.AddItem rst![套号名称]
Combo1.ItemData(Combo1.ListCount - 1) = rst![ID]
rst.MoveNext
Next i
Me.Combo1.ListIndex = 0
Set rst = Nothing
End Sub
Private Sub Option1_Click()
Combo1.Enabled = True
End Sub
Private Sub Option2_Click()
Combo1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If frmSetup.Height < 3555 Then
frmSetup.Height = frmSetup.Height + 100
End If
End Sub