📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "User Creation on Oracle"
ClientHeight = 3225
ClientLeft = 60
ClientTop = 450
ClientWidth = 5625
LinkTopic = "Form1"
ScaleHeight = 3225
ScaleWidth = 5625
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command4
Caption = "Quit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4200
TabIndex = 8
Top = 2640
Width = 975
End
Begin VB.CommandButton Command3
Caption = "Edit User"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2880
TabIndex = 7
Top = 2640
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "Create User"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 6
Top = 2640
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "Delete"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 5
Top = 2640
Width = 1095
End
Begin VB.ListBox List1
Height = 1815
Left = 3840
TabIndex = 4
Top = 360
Width = 1335
End
Begin VB.TextBox Text4
Height = 375
Left = 1560
TabIndex = 3
Top = 1800
Width = 1695
End
Begin VB.TextBox Text3
Height = 375
Left = 1560
TabIndex = 2
Top = 1320
Width = 1695
End
Begin VB.TextBox Text2
Height = 375
Left = 1560
TabIndex = 1
Top = 840
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Left = 1560
TabIndex = 0
Top = 360
Width = 1695
End
Begin VB.Line Line1
X1 = 5160
X2 = 240
Y1 = 2400
Y2 = 2400
End
Begin VB.Label Label4
Caption = "Expiry on"
Height = 255
Left = 360
TabIndex = 12
Top = 1800
Width = 975
End
Begin VB.Label Label3
Caption = "User Name"
Height = 255
Left = 360
TabIndex = 11
Top = 1320
Width = 975
End
Begin VB.Label Label2
Caption = "Password"
Height = 255
Left = 360
TabIndex = 10
Top = 840
Width = 975
End
Begin VB.Label Label1
Caption = "User"
Height = 255
Left = 360
TabIndex = 9
Top = 360
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim inp As String
inp = MsgBox("Are you sour to delete the user " & List1.Text & ".", vbQuestion + vbYesNo)
If inp = vbYes Then
Set USRec = New ADODB.Recordset
USRec.Open "select * from loginrec where puser='" & List1.Text & "'", USCon, adOpenDynamic, adLockOptimistic
Do While Not USRec.EOF
USRec.Delete
USRec.MoveNext
Loop
MsgBox "user " & List1.Text & " deleted."
blank
Form_Load
End If
End Sub
Private Sub Command2_Click()
Set USRec = New ADODB.Recordset
USRec.Open "select * from loginrec", USCon, adOpenDynamic, adLockOptimistic
USRec.AddNew
USRec.Fields("puser").Value = Text1.Text
USRec.Fields("ppass").Value = Text2.Text
USRec.Fields("uname").Value = Text3.Text
USRec.Fields("per").Value = Text4.Text
USRec.Update
MsgBox "user added to the record"
Form_Load
blank
End Sub
Private Sub Command3_Click()
Set USRec = New ADODB.Recordset
USRec.Open "select * from loginrec where puser='" & Text1.Text & "'", USCon, adOpenDynamic, adLockOptimistic
currentMode = EditMode
USRec.Fields("puser").Value = Text1.Text
USRec.Fields("ppass").Value = Text2.Text
USRec.Fields("uname").Value = Text3.Text
USRec.Fields("per").Value = Text4.Text
USRec.Update
MsgBox "user added to the record"
Form_Load
blank
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
' Dim objErr As ADODB.Error
' On Error GoTo err_test
'
' List1.Clear
'
' Set USRec = New ADODB.Recordset
' USRec.Open "loginrec", USCon, adOpenDynamic, adLockOptimistic
' Do While Not USRec.EOF
' List1.AddItem USRec.Fields("puser").Value
' USRec.MoveNext
' Loop
' Exit Sub
'err_test:
' MsgBox Error$
' For Each objErr In USCon.Errors
' MsgBox objErr.Description
' Next
' USCon.Errors.Clear
' Resume Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub List1_Click()
Set USRec = New ADODB.Recordset
USRec.Open "select * from loginrec where puser='" & List1.Text & "'", USCon, adOpenDynamic, adLockOptimistic
Text1.Text = USRec.Fields("puser").Value
Text2.Text = USRec.Fields("ppass").Value
Text3.Text = USRec.Fields("uname").Value
Text4.Text = USRec.Fields("per").Value
End Sub
Sub blank()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -