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

📄 frmuseredit.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmUserEdit 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "编辑用户信息"
   ClientHeight    =   2850
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4500
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2850
   ScaleWidth      =   4500
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_Ok 
      Caption         =   "确 定"
      Height          =   400
      Left            =   783
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   2280
      Width           =   1300
   End
   Begin VB.CommandButton Cmd_Cancel 
      Cancel          =   -1  'True
      Caption         =   "取 消"
      Height          =   400
      Left            =   2388
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2280
      Width           =   1300
   End
   Begin VB.Frame Frame1 
      Height          =   1935
      Left            =   240
      TabIndex        =   4
      Top             =   120
      Width           =   3975
      Begin VB.ComboBox cob_Type 
         Height          =   300
         ItemData        =   "FrmUserEdit.frx":0000
         Left            =   1560
         List            =   "FrmUserEdit.frx":000A
         Style           =   2  'Dropdown List
         TabIndex        =   8
         Top             =   840
         Width           =   2175
      End
      Begin VB.TextBox txtEmail 
         Height          =   270
         IMEMode         =   3  'DISABLE
         Left            =   1560
         MaxLength       =   20
         TabIndex        =   1
         Top             =   1347
         Width           =   2175
      End
      Begin VB.TextBox txtUserName 
         Height          =   270
         Left            =   1560
         MaxLength       =   20
         TabIndex        =   0
         Top             =   240
         Width           =   2175
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "用 户 名"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   7
         Top             =   240
         Width           =   720
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "电子邮箱"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   6
         Top             =   1395
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "用户类型"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   5
         Top             =   817
         Width           =   720
      End
   End
End
Attribute VB_Name = "FrmUserEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean
Public OriUser As String

Private Sub Cmd_Cancel_Click()
  Unload Me
End Sub

Private Sub Cmd_OK_Click()
  If Trim(txtUserName) = "" Then
    MsgBox "请输入用户名"
    txtUserName.SetFocus
    Exit Sub
  End If
  If Len(Trim(cob_Type.Text)) = 0 Then
    MsgBox "请选择用户类型"
    cob_Type.SetFocus
    Exit Sub
  End If
  If Len(Trim(txtEmail)) = 0 Then
    MsgBox "请输入电子邮箱地址"
    txtEmail.SetFocus
    Exit Sub
  End If
  
  With MyUser
  If Modify = False Or OriUser <> Trim(txtUserName) Then
    If .In_DB(MakeStr(txtUserName)) = True Then
      MsgBox "用户名已经存在,请重新输入"
      txtUserName.SetFocus
      txtUserName.SelStart = 0
      txtUserName.SelLength = Len(txtUserName)
      Exit Sub
    End If
  End If
  .UserName = MakeStr(txtUserName)
  If Trim(cob_Type.Text) = "系统管理员" Then
    .UserType = 1
  Else
    .UserType = 2
  End If
  .UserPwd = "111111"   '创建用户时的默认密码
  .Email = MakeStr(txtEmail)
  
  
  If Modify = False Then
    .Insert
    MsgBox "添加完成"
  Else
    .Update (OriUser)
    MsgBox "修改完成"
  End If
  End With
  Unload Me
End Sub

⌨️ 快捷键说明

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