📄 setuser1.frm
字号:
VERSION 5.00
Begin VB.Form setuser1
Caption = "编辑系统用户"
ClientHeight = 3420
ClientLeft = 60
ClientTop = 345
ClientWidth = 4515
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3420
ScaleWidth = 4515
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Comm2
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 510
Left = 2520
TabIndex = 5
Top = 2745
Width = 870
End
Begin VB.CommandButton Comm1
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 510
Left = 1350
TabIndex = 4
Top = 2745
Width = 870
End
Begin VB.Frame Frame1
Caption = "用户编辑"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 2310
Left = 630
TabIndex = 0
Top = 180
Width = 3165
Begin VB.TextBox Text1
Height = 330
Index = 0
Left = 1395
TabIndex = 1
Top = 495
Width = 1365
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "setuser1.frx":0000
Left = 1395
List = "setuser1.frx":000A
TabIndex = 3
Top = 1620
Width = 1500
End
Begin VB.TextBox Text1
Height = 330
Index = 1
Left = 1395
TabIndex = 2
Top = 1035
Width = 1365
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户级别"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 210
Index = 2
Left = 450
TabIndex = 8
Top = 1665
Width = 915
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "口 令"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 210
Index = 1
Left = 585
TabIndex = 7
Top = 1080
Width = 705
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 210
Index = 0
Left = 585
TabIndex = 6
Top = 540
Width = 690
End
End
End
Attribute VB_Name = "setuser1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cond As String
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{TAB}"
End If
End Sub
Private Sub Form_Load()
If flag = 2 Then
Text1(0).Text = setuser.Adodc1.Recordset.Fields("用户名")
Text1(1).Text = setuser.Adodc1.Recordset.Fields("口令")
Combo1.Text = setuser.Adodc1.Recordset.Fields("级别")
End If
End Sub
Private Sub Comm1_Click()
If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Combo1.Text) = "" Then
MsgBox "数据项不全,请重新设置", vbOKOnly, "信息提示"
Text1(0).SetFocus
Exit Sub
End If
If flag = 1 Then '添加操作
If setuser.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0
cond = "级别='" + Trim(Text1(0).Text) + "'"
setuser.Adodc1.Recordset.MoveFirst '每次从头开始查找
setuser.Adodc1.Recordset.Find (cond)
If Not setuser.Adodc1.Recordset.EOF() Then
MsgBox "存在完全相同的记录", vbOKOnly, "信息提示"
Text1(0).SetFocus
Exit Sub
End If
End If
setuser.Adodc1.Recordset.AddNew
setuser.Adodc1.Recordset.Fields("用户名") = Trim(Text1(0).Text)
setuser.Adodc1.Recordset.Fields("口令") = Val(Trim(Text1(1).Text))
setuser.Adodc1.Recordset.Fields("级别") = Trim(Combo1.Text)
setuser.Adodc1.Recordset.Update
recs = recs + 1
Else '修改操作
n = setuser.Adodc1.Recordset.AbsolutePosition
cond = "级别='" + Trim(Text1(0).Text) + "'"
setuser.Adodc1.Recordset.MoveFirst '每次从头开始查找
setuser.Adodc1.Recordset.Find (cond)
If Not setuser.Adodc1.Recordset.EOF() And setuser.Adodc1.Recordset.AbsolutePosition <> n Then
MsgBox "存在完全相同的记录", vbOKOnly, "信息提示"
setuser.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置
setuser.Adodc1.Recordset.Move (n - 1)
Text1(0).SetFocus
Exit Sub
End If
setuser.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置
setuser.Adodc1.Recordset.Move (n - 1)
setuser.Adodc1.Recordset.Fields("用户名") = Trim(Text1(0).Text)
setuser.Adodc1.Recordset.Fields("口令") = Val(Trim(Text1(1).Text))
setuser.Adodc1.Recordset.Fields("级别") = Trim(Combo1.Text)
setuser.Adodc1.Recordset.Update
End If
Unload Me
End Sub
Private Sub Comm2_Click()
Unload Me
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Call endata(KeyAscii)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -