如何通过VB6.0+Aeccess编写一个登陆窗口,使管理员输入正确的密码时,就登陆到主窗口中,密码可以修改,请高手附上源码

解决方案 »

  1.   

    '我的一个类似软件的登陆代码,供参考
    'LeeYoking Studio,http://www.xczy520.com/ttgg'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '登陆窗口
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim pswOK As Boolean    '密码正确标志
    Dim iCount As Integer   '密码限3次Private Sub cmdCancel_Click()
    On Error Resume Next
        End
    End SubPrivate Sub cmdOK_Click()
    On Error Resume Next
        '检查正确的密码
        If txtPassword.Text = psWord Then
            pswOK = True
            Unload Me
        Else
            pswOK = False
            iCount = iCount + 1
            If iCount = 3 Then MsgBox "密码输入3次错误,程序将关闭!", , "人事管理系统", vbCritical: End
            MsgBox "无效的密码,请重试!", vbCritical, "登录"
            txtPassword.SetFocus
            SendKeys "{Home}+{End}"
        End If
    End SubPrivate Sub Command1_Click()
    On Error Resume Next
        If txtPassword.Text = psWord Then
            frmLogin1.Show vbModal
        Else
            iCount = iCount + 1
            If iCount = 3 Then MsgBox "密码输入3次错误,程序将关闭!", vbCritical, "人事管理系统": End
            MsgBox "输入密码错误!", vbCritical, "错误"
            txtPassword.SetFocus
            SendKeys "{Home}+{End}"
        End If
     End SubPrivate Sub Form_Load()
    On Error Resume Next
        pswOK = False
        'Get password
        psWord = GetSetting(App.Title, "SET", "PSW", 1234)
    End SubPrivate Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
        If pswOK <> True Then End
    End Sub'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '修改密码窗口frmLogin1
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub cmdCancel_Click()
    On Error Resume Next
        Unload Me
    End SubPrivate Sub cmdOK_Click()
    On Error Resume Next
        '检查正确的密码
        If txtP1.Text <> "" And txtP1.Text = txtP2.Text Then
            SaveSetting App.Title, "SET", "PSW", txtP1.Text
            psWord = txtP1.Text
            WriteLog "修改密码成功。"
            Unload Me
        Else
            MsgBox "密码输入不一致或密码为空,请重试!", , "更改密码"
            txtP1.SetFocus
            SendKeys "{Home}+{End}"
        End If
    End Sub
      

  2.   

    呵呵,先建立一个数据库密码表,程序先进入LOGIN窗口,然后建立一个用户名的TEXT和一个密码的TEXT,用按钮的事件,与数据库内的权限比较就可以了.实现应该简单.自己作吧.我提个思路给你
      

  3.   

    '下面是我做的一个VFP登陆窗口的核心部分 tPsw是密码表,psw字段是密码字段
    '参考下吧,以后讲问题要清楚 免得浪费大家时间&&密码正确的情况下显示功能表单
    if thisform.text1.value=tPsw.psw then
    do form fMenu.scx
    THISFORM.RELEASE
    else
    i=i+1
    if i=3 then 
    messagebox('多次密码输入错误,程序即将关闭!',64,'严重错误')
    Clear Events
    Quit
    endif
    messagebox('输入的密码错误,请重新输入!',64,'密码错误')
    thisform.text1.setfocus
    thisform.text1.selstart=0
    thisform.text1.sellength=len(alltrim(thisform.text1.value))
    endif
      

  4.   

    Option Explicit
    Public usr, pas As String
    Public c, tim As Integer
    Public LoginSucceeded As Boolean      Sub seekx()On Error GoTo ErrHandler
         Dim pass As New ADODB.Recordset
            If pass.State = 1 Then pass.Close
           pass.Open "select * from xxx where user='" & txtUserName.Text & "'", link1, adOpenStatic, adLockReadOnly
        If pass.RecordCount < 1 Then
        usr = ""
        pas = ""
        Else
        usr = pass.Fields(0).Value
        pas = pass.Fields(1).Value
        
       ' MsgBox pas
        End If
        
             Exit Sub
    ErrHandler:
             MsgBox Err.Description, , Err.Number End SubPrivate Sub cmdCancel_Click()
        LoginSucceeded = False
        Me.Hide
        End
    End SubPrivate Sub cmdOK_Click()
        'check for correct password
       Dim dbs As Database
       Dim rst As Recordset
        Call seekx
        Dim stri As String
       
       
         
        If txtUserName.Text = usr And txtPassword.Text = pas And txtUserName <> "" Then
        
            LoginSucceeded = True
            Me.Hide
            MDIForm1.Enabled = True
            MDIForm1.Show
              frmLogin.Visible = False
     ' Unload frmLogin
        Else
          If tim = 3 Then
          Beep
            MsgBox "密码输入错误,请向管理员查询!", , "警告"
            End
            End If
            If txtUserName = "" Then
            Beep
            MsgBox "请输入用户名!", , "警告"
            Else
             If usr <> txtUserName.Text Then
             Beep
             MsgBox "查无此用户!", , "警告"
             txtUserName = ""
             txtUserName.SetFocus
             Else
              If txtPassword.Text = "" And c = 0 Then
              Beep
              MsgBox "请输入密码!", , "警告"
              Else
              c = 0
              If txtPassword.Text <> "" Then
               If txtUserName.Text= usr And txtPassword.Text<> pas Then
               Beep
               MsgBox "密码错误,请重新输入!", , "警告"
               tim = tim + 1
               End If
               End If
               End If
               
            txtPassword.SetFocus
            SendKeys "{Home}+{End}"
            End If
            End If
           txtPassword.Text = ""
      End If
     
    End SubPrivate Sub Form_Activate()
    tim = 1
    c = 1
    cmdOK.Default = True
    txtUserName.SetFocus
    End SubPrivate Sub Form_Load()If App.PrevInstance Then
        MsgBox "程序正在运行,请检查窗口是否被最小化。"
        End
    End IfLinkmdb
    txtUserName.Text = strUser
    txtPassword.Text = ""End SubPrivate Sub txtPassword_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    cmdOK.Default = True
    End If
    End SubPrivate Sub txtUserName_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    txtPassword.SetFocus
    cmdOK.Default = True
    End If
    End Sub    
        Public Sub Linkmdb() '连接数据库
           datapath = strDatapath
      
       
        On Error Resume Next
       
    If link1.State = 1 Then     '如果以连接过,则关闭,初始化下次事务
        link1.Close '
        End If
        
        link1.ConnectionString = "Provider=microsoft.jet.oledb.4.0;data source=" & datapath
        link1.Open
        
        End Sub
      

  5.   

    去源码天空找找:
    http://www.codesky.net/showcode.asp?uid=36531