userloginform.frm

来自「这个是VB环境开发的,我也是转载的把原来的Access数据库改成了SQl Ser」· FRM 代码 · 共 155 行

FRM
155
字号
VERSION 5.00
Begin VB.Form UserLoginForm 
   Appearance      =   0  'Flat
   BackColor       =   &H80000000&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "用 户 登 录"
   ClientHeight    =   1830
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3840
   ClipControls    =   0   'False
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   1830
   ScaleWidth      =   3840
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton CmdCancel 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      Caption         =   "取 消"
      Height          =   375
      Left            =   2520
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   1200
      Width           =   855
   End
   Begin VB.CommandButton CmdOk 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      Caption         =   "确 定"
      Default         =   -1  'True
      Height          =   375
      Left            =   960
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   1200
      Width           =   855
   End
   Begin VB.TextBox UserPassTxt 
      Height          =   315
      IMEMode         =   3  'DISABLE
      Left            =   1080
      PasswordChar    =   "*"
      TabIndex        =   3
      Text            =   "1"
      Top             =   720
      Width           =   2415
   End
   Begin VB.ComboBox UserNameCmb 
      Height          =   330
      Left            =   1080
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   240
      Width           =   2415
   End
   Begin VB.Label Label2 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      Caption         =   "用户口令:"
      ForeColor       =   &H80000008&
      Height          =   210
      Left            =   120
      TabIndex        =   1
      Top             =   720
      Width           =   1050
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      Caption         =   "用户名称:"
      ForeColor       =   &H80000008&
      Height          =   210
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   1050
   End
End
Attribute VB_Name = "UserLoginForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False






Option Explicit

Private Sub CmdCancel_Click()
  End
End Sub

Private Sub CmdOk_Click()
On Error GoTo l
Dim rs As Recordset
    Set rs = New ADODB.Recordset
    rs.Source = "select * from usertable"
    rs.Open , cn, adOpenKeyset, adLockOptimistic
    rs.Filter = "username='" & UserNameCmb & "'"
    If Not rs.BOF Or Not rs.EOF Then
        Usrpass = Trim(rs.Fields!userpwd)
        rs.Close
        Set rs = Nothing
        UsrName = UserNameCmb.Text
        If Usrpass = UserPassTxt.Text Then
          Unload Me
         ' Unload frmSplash
          'MDIMain.Show
         ' FrmM.Show
        Else
            MsgBox "你所输入的口令不对,请重新输入!", vbOKOnly, "口令错误"
            UserPassTxt.SetFocus
        End If
    Else
        MsgBox "  请选择用户名称!  ", vbInformation + vbOKOnly, "错误信息"
        Exit Sub
    End If
    Exit Sub
l:    MsgBox err.Description
End Sub

Private Sub Form_Load()
    Set rs = New ADODB.Recordset
    rs.Source = "select * from  usertable "
    rs.Open , cn, adOpenKeyset, adLockOptimistic
    Do Until rs.EOF
        UserNameCmb.AddItem rs.Fields("username")
        rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing

End Sub

⌨️ 快捷键说明

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