这些代码我有点不理解。

wbqc9912115 2004-02-23 02:49:12
以下是一个验证身份的登录窗体的代码。
用虚线包起来的这些我不是很明白,每当我运行之后都报一个相同的错误:
(实时错误91 -----对像变量或with块变量未设置。)
报错行我已标记如下。
???为什么没有看见连接sql server2000的代码呢。真是奇怪啊。(这个实例是以sql server 200 做的数据库。)

请各位指点迷津,小弟不胜感激。

========================================================================
////////////////////////////////////////////////////////////////////////
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long


Public OK As Boolean
Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long


sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
If lSize > 0 Then
txtUserName.Text = Left$(sBuffer, lSize)
Else
txtUserName.Text = vbNullString
End If
End Sub

/////////////////////////////////////////////////////////////////////////
==========================================================================

Private Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub


Private Sub cmdOK_Click()
'ToDo: create test for correct password
'check for correct password
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
'ToDo: create test for correct password
'check for correct password

UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then //。。。。。。。。。。。。。报错行
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If

miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub

...全文
30 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复

7,785

社区成员

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

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