frmlogin.frm

来自「能实现图书馆的图书操作」· FRM 代码 · 共 161 行

FRM
161
字号
VERSION 5.00
Begin VB.Form frmlogin 
   Caption         =   "Form1"
   ClientHeight    =   3930
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5490
   ForeColor       =   &H00FFC0C0&
   LinkTopic       =   "Form1"
   ScaleHeight     =   3930
   ScaleWidth      =   5490
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdexit 
      Caption         =   "退出"
      Height          =   375
      Left            =   3960
      TabIndex        =   7
      Top             =   3120
      Width           =   1095
   End
   Begin VB.CommandButton cmdok 
      Caption         =   "登陆"
      Height          =   375
      Left            =   2160
      TabIndex        =   6
      Top             =   3120
      Width           =   975
   End
   Begin VB.TextBox txtpwd 
      BackColor       =   &H00C0E0FF&
      Height          =   270
      IMEMode         =   3  'DISABLE
      Left            =   2640
      PasswordChar    =   "*"
      TabIndex        =   5
      Top             =   1920
      Width           =   2175
   End
   Begin VB.TextBox txtuserid 
      BackColor       =   &H00C0E0FF&
      Height          =   270
      Left            =   2640
      TabIndex        =   4
      Top             =   1440
      Width           =   2175
   End
   Begin VB.PictureBox Picture1 
      Height          =   4215
      Left            =   0
      Picture         =   "frmlogin.frx":0000
      ScaleHeight     =   4155
      ScaleWidth      =   1515
      TabIndex        =   0
      Top             =   0
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "密  码:"
      Height          =   255
      Left            =   1680
      TabIndex        =   3
      Top             =   1920
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "用户名:"
      Height          =   255
      Left            =   1680
      TabIndex        =   2
      Top             =   1440
      Width           =   855
   End
   Begin VB.Label Label1 
      Caption         =   " 图书管理系统"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   615
      Left            =   2040
      TabIndex        =   1
      Top             =   240
      Width           =   3135
   End
End
Attribute VB_Name = "frmlogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents rs As Recordset
Attribute rs.VB_VarHelpID = -1



Private Sub cmdexit_Click()
 End
End Sub

Private Sub cmdok_Click()
 
 Dim db As Connection
 Dim txtsql As String
  
 
 
 If txtuserid.Text = "" Then
    MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
     txtuserid.SetFocus
  Exit Sub
 End If
 
 

If txtpwd.Text = "" Then
 MsgBox " 密码不能为空!", vbExclamation + vbOKOnly, "警告"
     txtpwd.SetFocus
  Exit Sub
End If


 Set db = New Connection
 db.CursorLocation = adUseClient
 db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=book.mdb;"         '打开数据库
 Set rs = New Recordset
 txtsql = "select * from userinfo where userid='" & Trim(txtuserid.Text) & "' and  userpwd='" & Trim(txtpwd.Text) & "' "
 rs.Open txtsql, db, adOpenStatic, adLockOptimistic

  
  If rs.EOF Then
      MsgBox " 用户名或者密码错误!", vbExclamation + vbOKOnly, "警告"
      txtuserid.SetFocus
      Exit Sub
  End If



Unload Me
frmmain.Show

End Sub


Private Sub txtpwd_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
     cmdok.SetFocus
 End If
End Sub

Private Sub txtuserid_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
     txtpwd.SetFocus
  End If
End Sub

⌨️ 快捷键说明

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