📄 fcreatedb.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Begin VB.Form FCreateDB
Caption = "Create Database"
ClientHeight = 1245
ClientLeft = 1575
ClientTop = 2265
ClientWidth = 3750
LinkTopic = "Form1"
ScaleHeight = 1245
ScaleWidth = 3750
Begin VB.CommandButton cmdCreateDB
Caption = "Create Database"
Height = 555
Left = 1080
TabIndex = 0
Top = 360
Width = 1905
End
Begin MSComDlg.CommonDialog dlgCreateDB
Left = 180
Top = 360
_ExtentX = 847
_ExtentY = 847
_Version = 327680
End
End
Attribute VB_Name = "FCreateDB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Function GetDBName() As String
' Get the desired name using the common dialog
On Error GoTo ProcError
Dim strFileName As String
' setup the file save dialog file types
dlgCreateDB.DefaultExt = "mdb"
dlgCreateDB.DialogTitle = "Create Database"
dlgCreateDB.Filter = "VB Databases (*.mdb)|*.mdb"
dlgCreateDB.FilterIndex = 1
' setup flags
dlgCreateDB.Flags = _
cdlOFNHideReadOnly Or _
cdlOFNOverwritePrompt Or _
cdlOFNPathMustExist
' setting CancelError means the control will
' raise an error if the user clicks Cancel
dlgCreateDB.CancelError = True
' show the SaveAs dialog
dlgCreateDB.ShowSave
' get the selected name
strFileName = dlgCreateDB.filename
' dialog prompted for overwrite,
' so kill file if it exists
On Error Resume Next
Kill strFileName
ProcExit:
GetDBName = strFileName
Exit Function
ProcError:
strFileName = ""
Resume ProcExit
End Function
Private Sub CreateDB(strDBName As String)
' create the database
Dim db As Database
' if desired, you can specify a version or encrypt
' the database as the optional third parameter to
' the CreateDatabase method
Set db = DBEngine(0).CreateDatabase(strDBName, dbLangGeneral)
End Sub
Private Sub cmdCreateDB_Click()
On Error GoTo ProcError
Screen.MousePointer = vbHourglass
Dim strDBName As String
strDBName = GetDBName()
If Len(strDBName) > 0 Then
CreateDB strDBName
End If
ProcExit:
Screen.MousePointer = vbDefault
Exit Sub
ProcError:
MsgBox Err.Description
Resume ProcExit
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -