请教各位,小弟写了一个程序
里面需要用到一个密码登陆窗体.
源码:
Private Sub Command1_Click()
    Form2.Show
End Sub在Form2里有个text1 和 text2 
用来输入用户名和密码,当用户名和密码正确后.点击commnad1后直接打开form3
(最好是源码...,小弟巨菜)
谢谢了.

解决方案 »

  1.   

    private sub Command1_click()
        if acCheckUser=0 then
           form3.show
           unload me
        else
           msgbox "用户名或密码错误!"
        end if
    end subPrivate Function acCheckUser() As Integer
    On Error GoTo Errs
    Dim Sql As String
    Dim sPass As String, sName As String
        sPass = Me.txtPass.Text
        sName=me.txtName.text
        Sql = "select zlUser_Pass from zlUser where zlUser_Name='" & sName & "'"
        adoRs.Open Sql, adoCn, 1, 3
        If adoRs.RecordCount = 1 Then
            If sPass = Trim(adoRs("zlUser_Pass")) Then
                acCheckUser = 0
            Else
                acCheckUser = -1
            End If
        Else
            acCheckUser = -1
        End If
        adoRs.Close
        Exit Function
    Errs:
        MsgBox Err.Description
        acCheckUser = -1
    End Function
      

  2.   

    有没有简单一点的
    密码假设为 当用户为user 密码为123 就好了
    确定后直接关闭form2
    谢谢
      

  3.   

    小弟想实现当:
    If Text1.Text = "user" 
    Text2.Text = "123" 时,弹出form2请问格式错了么?还是其他的啊??
    他总是弹出对话框:Name or Password Error !
    我没有输错啊.....
    谢谢了~~~
    Private Sub Command1_Click()
        If Text1.Text = "user" + Text2.Text = "123" Then
        Form2.Show
    Else
         Call MsgBox("Name or Password Error !", vbOKOnly + 48, "WARNING !")
        End If
    End Sub
      

  4.   

    vb……》新建工程……》vb应用程序向导……》一系列选择之后在其中选中登录窗体,研究一下vb带的模板窗体。
    或者直接添加一个登录窗体
      

  5.   

    我添加了啊
    这些都有了
    目前是: form1 (主窗体),form2 (管理员窗体),在form1上面有两个text(分别是text1和text2) text1 用来输入name, text2 用来输入password.
    当密码和用户名正确后,打开form1.
    小弟不是很想用VB自带的窗体啊....
    想自己写.但是又看的不是很懂....
      

  6.   

    If (Text1.Text = "user") and (Text2.Text = "123") Then
      

  7.   

    If Text1.Text = "user" + Text2.Text = "123" Then
    什么意思?
    If Text1.Text = "user" and Text2.Text = "123" Then
      

  8.   

    private sub Command1_click()
        if isok then
           form3.show
           unload me
        else
           msgbox "用户名或密码错误!"
        end if
    end subPrivate Function isok() As boolean
    On Error GoTo Errs
    Dim Sql As String
    Dim sPass As String, sName As String
        sPass=txtPass.Text
        sName=txtName.text
        Sql = "select zlUser_Pass from zlUser where zlUser_Name='" & sName & "'"
        adoRs.Open Sql, adoCn, 1, 3
        If adoRs.RecordCount = 1 Then
            If sPass =iif(isnull(adoRs("zlUser_Pass")),"",adors("zluser_Pass")Then
                isok=true
            Else
                isok=false
            End If
        Else
            isok=false
        End If
        adoRs.Close
        Exit Function
    Errs:
        MsgBox Err.Description
        isok=false
    End Function
      

  9.   

    If Text1.Text = "user" and Text2.Text = "123" Then
      

  10.   

    建议楼主看看书或MSDN关于数据类型、运算符、语句的有关章节
      

  11.   

    Private Sub Command1_Click()
        If (Text1.Text = "user") and (Text2.Text = "123") Then
        Form2.Show
    Else
         Call MsgBox("Name or Password Error !", vbOKOnly + 48, "WARNING !")
        End If
    End Sub
      

  12.   

    If (Text1.Text = "user") and (Text2.Text = "123") Then
        Form2.Show