📄 form6.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmAddInfo
BackColor = &H00FFC0C0&
Caption = "添加用户信息"
ClientHeight = 3150
ClientLeft = 60
ClientTop = 390
ClientWidth = 4680
LinkTopic = "Form6"
ScaleHeight = 11550
ScaleWidth = 19080
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin VB.CommandButton cmdCancel
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 9240
TabIndex = 14
Top = 9840
Width = 2295
End
Begin VB.CommandButton cmdOK
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 6120
TabIndex = 13
Top = 9840
Width = 2295
End
Begin VB.CommandButton cmdReturn
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 12240
TabIndex = 12
Top = 9840
Width = 2415
End
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Caption = "添加用户信息"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 8415
Left = 4680
TabIndex = 0
Top = 720
Width = 9855
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 2295
Left = 960
TabIndex = 11
Top = 5160
Width = 8055
_ExtentX = 14208
_ExtentY = 4048
_Version = 393216
Rows = 5
Cols = 5
RowHeightMin = 20
BackColorBkg = 16761024
MergeCells = 2
AllowUserResizing= 3
End
Begin VB.TextBox txtSex
Height = 495
Left = 4320
TabIndex = 9
Top = 1800
Width = 2895
End
Begin VB.TextBox txtUserName
Height = 495
Left = 4320
TabIndex = 4
Top = 1080
Width = 2895
End
Begin VB.TextBox txtPassWord
Height = 495
IMEMode = 3 'DISABLE
Left = 4320
PasswordChar = "*"
TabIndex = 3
Top = 3360
Width = 2895
End
Begin VB.TextBox txtType
Height = 495
IMEMode = 3 'DISABLE
Left = 4320
PasswordChar = "*"
TabIndex = 2
Top = 2520
Width = 2895
End
Begin VB.TextBox txtID
Height = 495
IMEMode = 3 'DISABLE
Left = 4320
PasswordChar = "*"
TabIndex = 1
Top = 4080
Width = 2895
End
Begin VB.Label Label6
BackColor = &H00FFC0C0&
Caption = "性别:"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 10
Top = 1800
Width = 2295
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 8
Top = 1200
Width = 2295
End
Begin VB.Label Label2
BackColor = &H00FFC0C0&
Caption = "密码:"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 7
Top = 3360
Width = 2175
End
Begin VB.Label Label3
BackColor = &H00FFC0C0&
Caption = "用户类型:"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 6
Top = 2640
Width = 2175
End
Begin VB.Label Label4
BackColor = &H00FFC0C0&
Caption = "身份证号:"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 5
Top = 4200
Width = 2175
End
End
End
Attribute VB_Name = "frmAddInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdOK_Click()
If Not Testtext(txtUserName.Text) Then
MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "提示"
txtUserName.SetFocus
Exit Sub
End If
If Not Testtext(txtSex.Text) Then
MsgBox "请输入性别!", vbOKOnly + vbExclamation, "提示"
txtSex.SetFocus
Exit Sub
End If
If Not Testtext(txtType.Text) Then
MsgBox "请输入用户类型!", vbOKOnly + vbExclamation, "提示"
txtType.SetFocus
Exit Sub
End If
If Not Testtext(txtPassword.Text) Then
MsgBox "请输入密码!", vbOKOnly + vbExclamation, "提示"
txtPassword.SetFocus
Exit Sub
End If
If Not Testtext(txtID.Text) Then
MsgBox "请输入身份证号!", vbOKOnly + vbExclamation, "提示"
txtID.SetFocus
Exit Sub
End If
txtsql = "select * from 用户信息表 where 身份证号='" & Trim(txtID.Text) & "'"
Set Rs = ExecuteSQL(txtsql, MsgText)
If Rs.EOF = False Then
MsgBox "身份证号重复,请重新输入!", vbOKOnly + vbExclamation, "提示"
Rs.Close
txtID.SetFocus
Else
Rs.AddNew
Rs!用户名 = Trim(txtUserName.Text)
Rs!身份证号 = Trim(txtID.Text)
Rs!用户类型 = Trim(txtType.Text)
Rs!密码 = Trim(txtPassword.Text)
Rs!性别 = Trim(txtSex.Text)
Rs.Update
MsgBox "添加用户信息成功!", vbOKOnly + vbExclamation, "提示"
Rs.Close
Set Rs = Nothing
End If
End Sub
Private Sub cmdCancel_Click()
txtUserName.Text = ""
txtID.Text = ""
txtType.Text = ""
txtPassword.Text = ""
txtSex.Text = ""
txtUserName.SetFocus
End Sub
Private Sub cmdReturn_Click()
Unload Me
frmAdmainUser.Show
End Sub
Private Sub Form_Load()
Call Module1.connection
Dim textsql As String
Dim MsgText As String
Dim Rs As New ADODB.Recordset
End Sub
Private Sub Form_Unload(Cancel As Integer)
Rs.Close
End Sub
'显示Grid表头
Private Sub ShowTitle()
Dim i As Integer
With msgList
.Cols = 8
.TextMatrix(0, 1) = ""
.TextMatrix(0, 2) = "用户名"
.TextMatrix(0, 3) = "性别"
.TextMatrix(0, 4) = "用户类型"
.TextMatrix(0, 5) = "密码"
.TextMatrix(0, 6) = "身份证号"
'固定表头
.FixedRows = 1
'设置各列的对齐方式
For i = 0 To 6
.ColAlignment(i) = 0
Next i
'表头项居中
.FillStyle = flexFillRepeat
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
'设置单元大小
.ColWidth(0) = 300
.ColWidth(1) = 0
.ColWidth(2) = 1000
.ColWidth(3) = 2000
.ColWidth(4) = 2000
.ColWidth(5) = 1000
.ColWidth(6) = 1000
.ColWidth(7) = 600
.Row = 1
End With
End Sub
Private Sub ShowData()
Dim j As Integer
Dim i As Integer
txtsql = "select * from 用户信息表 "
Set Rs = ExecuteSQL(txtsql, MsgText)
With msgList
.Rows = 1
Do While Not Rs.EOF
.Rows = .Rows + 1
For i = 1 To Rs.Fields.Count
Select Case Rs.Fields(i - 1).Type
Case adDBDate
.TextMatrix(.Rows - 1, i) = Format(Rs.Fields(i - 1) & "", "yyyy-mm-dd")
Case Else
.TextMatrix(.Rows - 1, i) = Rs.Fields(i - 1) & ""
End Select
Next i
Rs.MoveNext
Loop
End With
Rs.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -