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

📄 frmuser1.frm

📁 用户登录及权限管理的通用的模块需要SQL数据库
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmUser1 
   Caption         =   "添加用户"
   ClientHeight    =   3000
   ClientLeft      =   45
   ClientTop       =   345
   ClientWidth     =   3540
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3000
   ScaleWidth      =   3540
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   324
      IMEMode         =   3  'DISABLE
      Index           =   3
      Left            =   1680
      TabIndex        =   1
      Top             =   720
      Width           =   1572
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   1800
      TabIndex        =   5
      Top             =   2280
      Width           =   972
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确认"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   600
      TabIndex        =   4
      Top             =   2280
      Width           =   972
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   324
      IMEMode         =   3  'DISABLE
      Index           =   2
      Left            =   1680
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   1680
      Width           =   1572
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   324
      IMEMode         =   3  'DISABLE
      Index           =   1
      Left            =   1680
      PasswordChar    =   "*"
      TabIndex        =   2
      Top             =   1200
      Width           =   1572
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   324
      Index           =   0
      Left            =   1680
      TabIndex        =   0
      Top             =   240
      Width           =   1572
   End
   Begin VB.Label Label4 
      Caption         =   "用 户 姓 名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "请确认密码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   1680
      Width           =   1455
   End
   Begin VB.Label Label2 
      Caption         =   "请输入密码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   1200
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "请输入用户名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   252
      Left            =   120
      TabIndex        =   6
      Top             =   240
      Width           =   1452
   End
End
Attribute VB_Name = "frmUser1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public txtSQL As String
Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    Dim sSQL As String
    Dim mrc As ADODB.Recordset
    Dim MsgText As String
    
    If gintUmode = 1 Then
        If Trim(Text1(0).Text) = "" Then
            MsgBox "请输入用户名称!", vbOKOnly + vbExclamation, "警告"
            Exit Sub
            Text1(0).SetFocus
        Else
            sSQL = "select * from users"
            Set mrc = ExecuteSQL(sSQL, MsgText)
            If Not mrc.EOF Then
                If Trim(mrc.Fields(0)) = Trim(Text1(0)) Then
                    MsgBox "用户已经存在,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
                    Text1(0).SetFocus
                    Text1(0).Text = ""
                    Text1(1).Text = ""
                    Text1(2).Text = ""
                    Exit Sub
                Else
                    mrc.MoveNext
                End If
            End If
        End If
        
        If Trim(Text1(1).Text) <> Trim(Text1(2).Text) Then
            MsgBox "两次输入密码不一样,请确认!", vbOKOnly + vbExclamation, "警告"
            Text1(1).SetFocus
            Text1(1).Text = ""
            Text1(2).Text = ""
            Exit Sub
            
        Else
            If Text1(1).Text = "" Then
                MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告"
                Text1(1).SetFocus
                Text1(1).Text = ""
                Text1(2).Text = ""
            Else
                mrc.AddNew
                mrc.Fields(0) = Trim(Text1(0).Text)
                mrc.Fields(1) = Trim(Text1(1).Text)
                mrc.Fields(2) = Trim(Text1(3).Text)
                mrc.Fields(3) = ""
                mrc.Update
                mrc.Close
                
                MsgBox "添加用户成功!", vbOKOnly + vbExclamation, "添加用户"
                
                frmUser.txtSQL = "select id,name,memo from users "
                 Unload Me
               
                frmUser.Show
                
                
            End If
        End If
    ElseIf gintUmode = 2 Then
            sSQL = "select name from users where id= '" & Trim(Text1(0)) & "'"
            Set mrc = ExecuteSQL(sSQL, MsgText)
            
            If Not mrc.EOF Then
                mrc.Fields(0) = Trim(Text1(3))
                mrc.Update
                mrc.Close
            End If
            
            
            frmUser.txtSQL = "select id,name,memo from users "
            Unload Me
            frmUser.Show
            
        
    End If
    
        
        
End Sub

Private Sub Form_Load()
    Dim mrc As ADODB.Recordset
    Dim MsgText As String
    
    If gintUmode = 2 Then
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        
        If Not mrc.EOF Then
            Text1(0) = mrc.Fields(0)
            Text1(0).Enabled = False
            
            Text1(3) = mrc.Fields(1)
            Text1(1) = "********"
            Text1(2) = "********"
            
            mrc.Close
        End If
    End If
End Sub

⌨️ 快捷键说明

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