📄 frmaddnew.frm
字号:
VERSION 5.00
Object = "{653A556A-745E-476A-BB7C-20AB9DC0A4FB}#5.0#0"; "EXButton.ocx"
Begin VB.Form frmAddNew
Caption = "电子通讯录-新增用户"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 5535
ForeColor = &H00404040&
Icon = "frmAddNew.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3195
ScaleWidth = 5535
StartUpPosition = 2 '屏幕中心
Begin VB.PictureBox Picture1
BackColor = &H00FF80FF&
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = -1 'True
EndProperty
Height = 375
Left = 2520
ScaleHeight = 315
ScaleWidth = 1155
TabIndex = 10
Top = 2280
Width = 1215
End
Begin EXButton.ExBtn ExBtn2
Cancel = -1 'True
Height = 375
Left = 4320
TabIndex = 9
Top = 2400
Width = 975
_ExtentX = 1720
_ExtentY = 661
ForeColor = 16711680
CRad = 3
Skin = "frmAddNew.frx":030A
Style = 4
Caption = "取 消"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin EXButton.ExBtn ExBtn1
Default = -1 'True
Height = 375
Left = 4320
TabIndex = 8
Top = 1800
Width = 975
_ExtentX = 1720
_ExtentY = 661
ForeColor = 16711680
CRad = 3
Skin = "frmAddNew.frx":19AE
SkinPR = 5
Style = 4
Caption = "确 定"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.TextBox txtYZM
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1200
TabIndex = 7
Top = 2280
Width = 1215
End
Begin VB.TextBox txtPWD1
Height = 375
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 6
Top = 1560
Width = 2535
End
Begin VB.TextBox txtPWD
Height = 375
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 5
Top = 960
Width = 2535
End
Begin VB.TextBox txtName
Height = 375
Left = 1200
TabIndex = 4
Top = 360
Width = 2535
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "密码确认:"
ForeColor = &H00FF0000&
Height = 180
Left = 240
TabIndex = 3
Top = 1560
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "验证码:"
ForeColor = &H00FF0000&
Height = 180
Left = 240
TabIndex = 2
Top = 2280
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "密 码:"
ForeColor = &H00FF0000&
Height = 180
Left = 240
TabIndex = 1
Top = 960
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户名:"
ForeColor = &H00FF0000&
Height = 180
Left = 240
TabIndex = 0
Top = 360
Width = 720
End
End
Attribute VB_Name = "frmAddNew"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub ExBtn1_Click()
Dim mrc As ADODB.Recordset
Dim txtSQL As String
'检验输入数据
If Len(txtName.Text) = 0 Then
MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtName.SetFocus
Exit Sub
End If
If Len(txtPWD.Text) = 0 Then
MsgBox "请输入密码!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtPWD.SetFocus
Exit Sub
End If
If Len(txtPWD1.Text) = 0 Then
MsgBox "请确认密码!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtPWD1.SetFocus
Exit Sub
End If
If Len(txtYZM.Text) = 0 Then
MsgBox "请输入验证码!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtYZM.SetFocus
Exit Sub
End If
If Trim(txtPWD.Text) <> Trim(txtPWD1.Text) Then
MsgBox "密码前后输入不一致,请重新输入!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtPWD1.SetFocus
txtPWD1.Text = ""
Exit Sub
End If
If Trim(txtYZM.Text) <> Picture1.Tag Then
MsgBox "验证码输入错误,请重新输入!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtYZM.Text = ""
txtYZM.SetFocus
Call YZM
Exit Sub
End If
txtSQL = "Select * from Tbl_Users where 用户名 = '" & Trim(txtName.Text) & "'" '查询是否已存在该用户名
Set mrc = ExecuteSQL(txtSQL)
If mrc.EOF = False Then
MsgBox "该用户名已存在!", vbOKOnly + vbExclamation, "电子通讯录-提示"
txtName.SetFocus
txtName.Text = ""
mrc.Close
Exit Sub
End If
'全部判断正确,则添加该用户
txtSQL = "Select * from Tbl_Users"
Set mrc = ExecuteSQL(txtSQL)
mrc.AddNew
mrc.Fields(0) = Trim(txtName.Text)
mrc.Fields(1) = EncodePassWord(Trim(txtPWD1.Text)) '调用加密函数,并储存加密后的密码
mrc.Update
mrc.Close
MsgBox "用户添加成功!", vbOKOnly + vbInformation, "电子通讯录-提示"
txtName.SetFocus
txtName.Text = ""
txtPWD.Text = ""
txtPWD1.Text = ""
txtYZM.Text = ""
Call YZM
End Sub
Private Sub ExBtn2_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Call YZM
End Sub
Private Sub YZM()
Dim i As Integer
Randomize
i = Int(Rnd * (9999 - 1000 + 1) + 1000)
Picture1.Cls
Picture1.Print i
Picture1.Tag = i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -