回 帖 发 新 帖 刷新版面

主题:VB毕业设计求助

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 = ""
   
    Else
        txtUserName.Text = vbNullString
    End If
    

    OK = False
    miCount = 0
End Sub



Private 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 = ""
            End If
        End If
    End If
    
    miCount = miCount + 1
    If miCount = 3 Then
        Me.Hide
    End If
    Exit Sub
End Sub

每次调试结果都是 对象变量或with块变量未设置,高手来帮我看看,
毕业设计紧急求助

回复列表 (共2个回复)

沙发

If mrc.EOF = True Then  就是这里变量未设置

板凳

QQ:115421109

VB 毕业设计,给你!

我来回复

您尚未登录,请登录后再回复。点此登录或注册