frmuserdelete.frm

来自「用vb实现的图书管理系统」· FRM 代码 · 共 150 行

FRM
150
字号
VERSION 5.00
Begin VB.Form frmUserDelete 
   Caption         =   "删除用户"
   ClientHeight    =   3720
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5640
   LinkTopic       =   "Form1"
   ScaleHeight     =   3720
   ScaleWidth      =   5640
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   495
      Left            =   2760
      TabIndex        =   5
      Top             =   3000
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Height          =   495
      Left            =   720
      TabIndex        =   4
      Top             =   3000
      Width           =   1575
   End
   Begin VB.TextBox txtPassword 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2160
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   2160
      Width           =   2055
   End
   Begin VB.TextBox txtName 
      Height          =   375
      Left            =   2160
      TabIndex        =   2
      Top             =   1560
      Width           =   2055
   End
   Begin VB.Label Label3 
      Caption         =   "图书馆管理系统"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1560
      TabIndex        =   6
      Top             =   600
      Width           =   2415
   End
   Begin VB.Label Label2 
      Caption         =   "密 码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   1
      Top             =   2280
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "用户名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   0
      Top             =   1680
      Width           =   855
   End
End
Attribute VB_Name = "frmUserDelete"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String

Dim N As Boolean
N = True
If Trim(txtName.Text) = "" Then
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""
txtName.SetFocus
N = False
End If
If Trim(txtPassword.Text) = "" Then
MsgBox "密码不能为空", vbOKOnly + vbExclamation, ""
txtPassword.SetFocus
N = False
End If
If N = True Then
Set conn = New ADODB.Connection

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=book.mdb;Persist Security Info=False"
conn.Open

sql = "select*from UserInfo where Username = '"
sql = sql + txtName.Text + "' and Password='" + txtPassword.Text + "'"
Set rs = conn.Execute(sql)
If rs.EOF Or rs.BOF Then
 MsgBox "用户名或口令错误,请检查!"
 
 N = False
 End If
 rs.Close
 End If
 If N = True Then
 rs.Open sql, conn, adOpenKeyset, adLockPessimistic
 rs.Delete
 rs.Update
 rs.Close
 MsgBox "删除用户成功!"
 End If
 
 
End Sub

Private Sub Command2_Click()
Unload Me

End Sub

⌨️ 快捷键说明

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