Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
'记录确定次数
Dim miCount As Integer
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 = "1234"
Else
txtUserName.Text = vbNullString
End If
OK = False
miCount = 0
End SubPrivate Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
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 = "1234"
End If
End If
End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub
Private Sub Label2_Click()End SubPrivate Sub lblLabels_Click(Index As Integer)End SubPrivate Sub txtPassword_Change()End SubPrivate Sub txtUserName_Change()End Sub
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
'记录确定次数
Dim miCount As Integer
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 = "1234"
Else
txtUserName.Text = vbNullString
End If
OK = False
miCount = 0
End SubPrivate Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
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 = "1234"
End If
End If
End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub
Private Sub Label2_Click()End SubPrivate Sub lblLabels_Click(Index As Integer)End SubPrivate Sub txtPassword_Change()End SubPrivate Sub txtUserName_Change()End Sub
解决方案 »
- 可读性和简洁性以及效率,到底选择哪个?
- 谁用过ImagXpress Professional 控件
- 有关VB打印问题 ?
- 报刊一周出版2期(周1与周3),随意给个时间段(如2001-1-2~2003-2-4)当然这个时间是不确定的。请问这段时间内一共出了几期。
- 高分,如何用vbs创建一个windows用户,并且放入user组中~~~~~~~~~~~~~~~~
- 一个问题,不知道怎么回事……
- 请问哪位VB高手可以帮帮在下一个小忙!(谢谢)
- 关于vb做的dll,那位好心人帮帮忙啊
- 循环嵌套问题。
- 我用datagrid帮定ado控件,在做删除和添加操作的时候,datagrid不随ado的变化而变化怎么办?
- 求 大虾 帮做下 这个题
- vb的webbroswer显示网页,点击网页按钮,如何执行vb程序
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 = "1234"
End If 密码在user_Info 表中的第二个字段
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html