[求助]对象变量或with块变量未设置的问题
Option ExplicitPrivate miCount As Integer
'******************************************
Private Sub Form_Load()
Call cboDataUser
End Sub
'*****************************************
Private Sub cmdCancel_Click()
'取消,则gLoginSucceeded为False
gLoginSucceeded = False
End
End Sub
'********************************
Private Sub cmdOK_Click()
Dim txtsql As String
Dim rstLogin As ADODB.Recordset
Dim flag As String
gUserName = ""
gUserKind = ""
If Trim(cboLogin.Text = "") Then
MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "警告"
cboLogin.SetFocus
Else
txtsql = "select * from tbUser where UserId = '" & cboLogin.Text & "'"
flag = ExecuteSQL(txtsql, rstLogin, False)
If Trim(rstLogin.Fields(1)) = Trim(txtPassword.Text) Then
gUserName = Trim(cboLogin.Text)
gUserKind = Trim(rstLogin.Fields(2))
gLoginSucceeded = True
rstLogin.Close
Me.Hide
frmMain.Show
Else
MsgBox "密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub
' ******************************************************************************
'过程名:cboDataUser
'说 明:为用户名列表赋值
'参 数:无
'返回值:无
' ******************************************************************************v
Public Sub cboDataUser()
Dim res As String
Dim txtsql As String
Dim rstcbo As ADODB.Recordset
Dim i As Integer
txtsql = "select UserId from tbUser"
res = ExecuteSQL(txtsql, rstcbo, False)
If rstcbo.RecordCount <> 0 Then'这地方出现91错误
For i = 0 To rstcbo.RecordCount - 1
cboLogin.AddItem (rstcbo.Fields(0))
rstcbo.MoveNext
Next
End If
End Sub