📄 frmsecure.frm
字号:
VERSION 5.00
Begin VB.Form frmSecure
BorderStyle = 3 'Fixed Dialog
Caption = "Secure"
ClientHeight = 1545
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3750
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 912.837
ScaleMode = 0 'User
ScaleWidth = 3521.047
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox txtUserName
Height = 345
Left = 1290
TabIndex = 1
Top = 135
Width = 2325
End
Begin VB.CommandButton cmdOK
Caption = "&OK"
Default = -1 'True
Height = 390
Left = 495
TabIndex = 4
Top = 1020
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "&Cancel"
Height = 390
Left = 2100
TabIndex = 5
Top = 1020
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 3
Top = 525
Width = 2325
End
Begin VB.Label lblUserName
Caption = "&User Name:"
Height = 270
Index = 0
Left = 105
TabIndex = 0
Top = 150
Width = 1080
End
Begin VB.Label lblPassword
Caption = "&Password:"
Height = 270
Index = 1
Left = 105
TabIndex = 2
Top = 540
Width = 1080
End
End
Attribute VB_Name = "frmSecure"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
' if there is an error goto the code labeled by ERR_Form_Load
On Error GoTo ERR_Form_Load:
' local variables used to hold the user name and password
Dim sUser As String
Dim sPassword As String
With DBEngine
' set the system database INI path (registry key)
DBEngine.IniPath = GetINIPath
' set system database file
.SystemDB = GetWorkgroupDatabase
' set default user information
sUser = "Admin"
sPassword = "myturn"
' assign default user information
.DefaultUser = sUser
.DefaultPassword = sPassword
' display current system database
MsgBox "The system database is " & .SystemDB, vbInformation
End With
Exit Sub
ERR_Form_Load:
' display the error information and then end the application
With Err
MsgBox "ERROR #" & .Number & ": " & .Description, vbExclamation, _
"ERROR"
End With
Unload Me
End Sub
Private Sub cmdOK_Click()
' if an error occurs then goto the code labeled by ERR_cmdOK_Click
On Error GoTo ERR_cmdOK_Click:
' local object variables used to hold the database, recordset, and
' workspace
Dim db As Database
Dim rs As Recordset
Dim ws As Workspace
' local variable used to store database path and name
Dim sDBName As String
' local variables used to store the user name and password
Dim sUserName As String
Dim sPassword As String
' if there is no user name then inform the user and exit the procedure
' if there is a user name assign the name and password
If (txtUserName = "") Then
MsgBox "You must enter a user name.", vbExclamation, "ERROR"
txtUserName.SetFocus
Exit Sub
Else
sUserName = txtUserName
sPassword = txtPassword
End If
' create a new workspace for the user
Set ws = DBEngine.CreateWorkspace("NewWorkspace", sUserName, sPassword)
' obtain the database name and path from ReadINI and then open the
' database
sDBName = DBPath
Set db = ws.OpenDatabase(sDBName)
' insure that we have connected by creating a recordset of some data
Set rs = db.OpenRecordset("SELECT * FROM Customers")
' inform the user that we are successful
MsgBox "User " & txtUserName & " connected successfully!", vbInformation, "SUCCESS"
Exit Sub
ERR_cmdOK_Click:
' display the error information and then end the application
With Err
MsgBox "ERROR #" & .Number & ": " & .Description, vbExclamation, _
"ERROR"
End With
End Sub
Private Sub cmdCancel_Click()
' end the application
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -