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

📄 frm用户管理.frm

📁 1. 观察计算机显示系统构成
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frm用户管理 
   Caption         =   "用户管理"
   ClientHeight    =   1605
   ClientLeft      =   60
   ClientTop       =   405
   ClientWidth     =   3825
   LinkTopic       =   "Form1"
   ScaleHeight     =   1605
   ScaleWidth      =   3825
   StartUpPosition =   3  '窗口缺省
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   "D:\桌面\新建文件夹\db2.mdb"
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   1080
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "用户管理表"
      Top             =   2400
      Visible         =   0   'False
      Width           =   1515
   End
   Begin VB.CommandButton ComDelete 
      Caption         =   "删除"
      Height          =   375
      Left            =   1920
      TabIndex        =   8
      Top             =   1200
      Width           =   885
   End
   Begin VB.CommandButton ComAdd 
      Caption         =   "添加"
      Height          =   375
      Left            =   0
      TabIndex        =   7
      Top             =   1200
      Width           =   885
   End
   Begin VB.CommandButton ComSave 
      Caption         =   "保存"
      Height          =   375
      Left            =   960
      TabIndex        =   6
      Top             =   1200
      Width           =   885
   End
   Begin VB.CommandButton ComEnd 
      Caption         =   "退出"
      Height          =   375
      Left            =   2880
      TabIndex        =   5
      Top             =   1200
      Width           =   885
   End
   Begin VB.Frame Frame1 
      Height          =   1095
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   3795
      Begin VB.TextBox Text1 
         Height          =   285
         IMEMode         =   3  'DISABLE
         Index           =   1
         Left            =   1515
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   660
         Width           =   2055
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   1530
         Locked          =   -1  'True
         TabIndex        =   1
         Top             =   240
         Width           =   2055
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "用户名                                      "
         Height          =   330
         Left            =   675
         TabIndex        =   4
         Top             =   330
         Width           =   870
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "密 码        "
         Height          =   285
         Left            =   720
         TabIndex        =   3
         Top             =   720
         Width           =   645
      End
   End
End
Attribute VB_Name = "frm用户管理"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer

Dim myrs1 As Recordset

Private Sub Combo1_Click()
 Text1(1).SetFocus
End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = 13 Then
  Text1(1).SetFocus
 Else
 End If
End Sub

Private Sub Form_Load()
 On Error Resume Next
  frm主窗体.StatusBar1.Panels(1) = Me.Caption
  Data1.DatabaseName = App.Path & "\db2.mdb"
  Data1.RecordSource = "select * from 用户管理表"
  Data1.Refresh
    If Data1.Recordset.RecordCount > 0 Then
       Data1.Recordset.MoveFirst
       Do While Data1.Recordset.EOF = False
         Combo1.AddItem (Data1.Recordset.Fields("用户名称"))
         Data1.Recordset.MoveNext
       Loop
    Else
    End If
  Text1(1).MaxLength = 6
  ComSave.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
 frm主窗体.Enabled = True
 frm主窗体.StatusBar1.Panels(1) = "杨扬工作室 作者:小杨"
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
 On Error Resume Next
  Select Case Index
    Case 0
      If Index = 0 And KeyCode = vbKeyReturn Then Text1(1).SetFocus
    Case 1
      If Index = 1 And KeyCode = vbKeyReturn Then ComSave.SetFocus
  End Select
End Sub
Private Sub ComAdd_Click()
  ComSave.Enabled = True
  ComAdd.Enabled = False
  Combo1.Locked = False
End Sub
Private Sub ComSave_Click()
 On Error Resume Next
  Data1.RecordSource = "select * from 用户管理表 where 用户名称='" + Combo1.Text + "'"
  Data1.Refresh
   If Data1.Recordset.RecordCount > 0 Then
   MsgBox "用户名已经存在,注册不成功!", , "信息提示"
   Combo1.Text = ""
   Combo1.SetFocus
  Else
 
  Set myrs1 = mydb.OpenRecordset("用户管理表", dbOpenTable)
      myrs1.AddNew
      If Combo1.Text <> "" Then myrs1.Fields(0) = Combo1.Text
      If Text1(1).Text <> "" Then
      myrs1.Fields(1) = Text1(1).Text
      myrs1.Fields(2) = "0"
      myrs1.Fields(3) = "0"
      myrs1.Fields(4) = "0"
      myrs1.Fields(5) = "0"
      myrs1.Fields(6) = "0"
      Else
      End If
      myrs1.Update
      myrs1.Close
      mydb.Close
      Data1.Refresh
  ComSave.Enabled = False
  ComAdd.Enabled = True
  End If
End Sub
Private Sub ComDelete_Click()
 On Error Resume Next
  Data1.RecordSource = "select * from 用户管理表 where 用户名称='" + Combo1.Text + "'"
  Data1.Refresh
  If Trim(Combo1.Text) = Name1 Then
    MsgBox "不能删除当前用户名称!", , "提示信息"
  Else
       If Data1.Recordset.RecordCount <> 0 Then
           Data1.Recordset.Delete
           MsgBox "信息删除成功!", , "信息提示"
       Else
           MsgBox "请选择要删除的用户名称", , "信息提示"
           Combo1.SetFocus
       End If
  End If
End Sub
Private Sub ComEnd_Click()
  frm主窗体.Enabled = True
  Unload Me
End Sub


⌨️ 快捷键说明

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