⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 sample login method made in visual basic
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "DB Login Sample - WWJD? "
   ClientHeight    =   1890
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4050
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   1890
   ScaleWidth      =   4050
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "&Login"
      Height          =   375
      Left            =   2760
      TabIndex        =   2
      Top             =   1320
      Width           =   1095
   End
   Begin VB.TextBox txtPassword 
      Height          =   285
      IMEMode         =   3  'DISABLE
      Left            =   1680
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   960
      Width           =   2175
   End
   Begin VB.TextBox txtUserName 
      Height          =   285
      Left            =   1680
      TabIndex        =   0
      Top             =   600
      Width           =   2175
   End
   Begin VB.Label Label2 
      Caption         =   "Password"
      Height          =   255
      Left            =   240
      TabIndex        =   4
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "UserName:"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   600
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As New ADODB.Recordset 'rs is the recordset that is used to check the username & password
Dim sql As String 'Used to handle the sql statment
Dim sConn As String 'Connection String
Dim iChances As Integer '3 Strikes Counter
Dim oSHA256 As CSHA256 'Ecryption Handler
    
Private Sub Command1_Click()
Dim PassCheck As String 'Used to Compare the password once it has been encrypted

Set oSHA256 = New CSHA256

PassCheck = oSHA256.SHA256(txtPassword)

'Tell vb what database to use
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Sample.mdb" & ";Persist Security Info=False"
'This is where the username and password are checked within the database
sql = "SELECT * FROM tblLogin Where Username ='" & txtUserName.Text & _
"' And Password ='" & PassCheck & "'"

'Open the recordset for use in the login
rs.Open sql, sConn, adOpenDynamic, adLockReadOnly, adCmdText

    If Not rs.EOF Then
       Form2.Show 'Login was sucessful now show another form
       Unload Me ' Unload this one
       Else
       'The login failed
       MsgBox "Wrong username or password", , "Login Error"
       iChances = iChances + 1 ' Another chance gone
       If iChances = 3 Then Unload Me ' All chances gone
    End If
Set oSHA256 = Nothing
'Close the recordset
rs.Close
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -