?? form1.frm
字號:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form form1
Caption = "動態創建數據庫"
ClientHeight = 4830
ClientLeft = 60
ClientTop = 345
ClientWidth = 9000
LinkTopic = "Form2"
ScaleHeight = 4830
ScaleWidth = 9000
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox combo1
Height = 300
ItemData = "form1.frx":0000
Left = 3510
List = "form1.frx":0002
Style = 2 'Dropdown List
TabIndex = 14
Top = 705
Width = 1275
End
Begin VB.TextBox Text2
Height = 300
Left = 7140
TabIndex = 12
Text = "124"
Top = 210
Width = 1545
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 3030
Left = 435
TabIndex = 11
Top = 1110
Width = 8235
_ExtentX = 14526
_ExtentY = 5345
_Version = 393216
BackColorBkg = 14737632
BorderStyle = 0
End
Begin VB.CommandButton Command3
Caption = "退出"
BeginProperty Font
Name = "宋體"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 465
Left = 6885
TabIndex = 10
Top = 4290
Width = 1815
End
Begin VB.CommandButton Command2
Caption = "生成表"
BeginProperty Font
Name = "宋體"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 465
Left = 4620
TabIndex = 9
Top = 4290
Width = 2145
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 330
Left = 6630
TabIndex = 8
Top = 675
Width = 2085
End
Begin VB.TextBox Text4
Height = 300
Left = 1530
TabIndex = 7
Text = "123"
Top = 195
Width = 4065
End
Begin VB.TextBox Text3
Height = 270
Left = 5520
TabIndex = 2
Top = 750
Width = 975
End
Begin VB.TextBox Text1
Height = 300
Left = 1080
TabIndex = 0
Top = 690
Width = 1620
End
Begin VB.Label Label6
Caption = "表格名稱:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 6090
TabIndex = 13
Top = 210
Width = 1170
End
Begin VB.Label Label5
Caption = "數據庫名:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 390
TabIndex = 6
Top = 225
Width = 1095
End
Begin VB.Label Label4
Caption = "大小:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 4845
TabIndex = 5
Top = 720
Width = 765
End
Begin VB.Label Label3
Caption = "類型:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2850
TabIndex = 4
Top = 720
Width = 765
End
Begin VB.Label Label2
Caption = "名稱:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
Left = 405
TabIndex = 3
Top = 705
Width = 900
End
Begin VB.Label Label1
Height = 420
Left = 240
TabIndex = 1
Top = 180
Width = 1155
End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gsDataType As String
Dim FileName As String
Private Sub Combo1_Change()
Text3.Text = "50"
End Sub
Private Sub combo1_Click()
Dim nFldType As Integer
Text3.Text = SetFldProperties(combo1.ItemData(combo1.ListIndex))
Text3.Enabled = False
nFldType = combo1.ItemData(combo1.ListIndex)
If gsDataType <> "Microsoft Access" Then
If nFldType = dbText Then
'允許輸入字段長度
Text3.Enabled = True
Text3.Text = "50"
End If
'對 MDB 數據庫僅做下面的部分
Exit Sub
End If
If nFldType = dbText Then
'允許輸入字段長度
Text3.Enabled = True
'Access UI 的缺省字段大小
Text3.Text = "50"
'對 memo 和 text 有效
End If
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
For i = 0 To 12
If MSFlexGrid1.TextMatrix(i, 1) <> "" Then j = i + 1
Next i
If Text1.Text <> "" Then
If Text1.Text <> "" Then MSFlexGrid1.TextMatrix(j, 1) = Text1.Text
If combo1.Text <> "" Then MSFlexGrid1.TextMatrix(j, 2) = combo1.ItemData(combo1.ListIndex)
If Text3.Text <> "" Then MSFlexGrid1.TextMatrix(j, 3) = Text3.Text
Text1.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Dim PathName As String
PathName = App.Path
Dim aaa As Variant
Dim i As Integer
Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
Set MyDatabase = CreateDatabase(App.Path & "\" & Text4.Text, dbLangGeneral)
Set MyTable = MyDatabase.CreateTableDef(Text2.Text)
For i = 1 To 12
If MSFlexGrid1.TextMatrix(i, 1) <> "" Then
aaa = MSFlexGrid1.TextMatrix(i, 2)
Set MyField = MyTable.CreateField(MSFlexGrid1.TextMatrix(i, 1), aaa, 50)
MyTable.Fields.Append MyField
End If
Next i
MyDatabase.TableDefs.Append MyTable
End Sub
Private Sub Form_Load()
combo1.AddItem "Boolean"
combo1.ItemData(combo1.NewIndex) = dbBoolean
combo1.AddItem "Byte"
combo1.ItemData(combo1.NewIndex) = dbByte
combo1.AddItem "Integer"
combo1.ItemData(combo1.NewIndex) = dbInteger
combo1.AddItem "Long"
combo1.ItemData(combo1.NewIndex) = dbLong
combo1.AddItem "Currency"
combo1.ItemData(combo1.NewIndex) = dbCurrency
combo1.AddItem "Single"
combo1.ItemData(combo1.NewIndex) = dbSingle
combo1.AddItem "Double"
combo1.ItemData(combo1.NewIndex) = dbDouble
combo1.AddItem "Date/Time"
combo1.ItemData(combo1.NewIndex) = dbDate
combo1.AddItem "Text"
combo1.ItemData(combo1.NewIndex) = dbText
combo1.AddItem "Binary"
combo1.ItemData(combo1.NewIndex) = dbLongBinary
combo1.AddItem "Memo"
combo1.ItemData(combo1.NewIndex) = dbMemo
MSFlexGrid1.Cols = 4
MSFlexGrid1.Rows = 15
MSFlexGrid1.ColWidth(0) = 12 * 25 * 2
MSFlexGrid1.ColWidth(1) = 12 * 25 * 8
MSFlexGrid1.ColWidth(2) = 12 * 25 * 7
MSFlexGrid1.ColWidth(3) = 12 * 25 * 7
MSFlexGrid1.TextMatrix(0, 0) = "序號"
MSFlexGrid1.TextMatrix(0, 1) = "名稱"
MSFlexGrid1.TextMatrix(0, 2) = "類型"
MSFlexGrid1.TextMatrix(0, 3) = "大小"
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
combo1.SetFocus
End If
If KeyCode = vbKeyDown Then
combo1.SetFocus
End If
End Sub
Private Sub Text3_Change()
If Val(Text3.Text) > 250 Then Text3.Text = "250"
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Command1.SetFocus
End If
If KeyCode = vbKeyRight Then
Command1.SetFocus
End If
If KeyCode = vbKeyLeft Then
combo1.SetFocus
End If
End Sub
Function SetFldProperties(rnType As Integer) As Integer
Select Case rnType
Case dbBoolean
SetFldProperties = 1
Case dbByte
SetFldProperties = 1
Case dbInteger
SetFldProperties = 2
Case dbLong
SetFldProperties = 4
Case dbCurrency
SetFldProperties = 8
Case dbSingle
SetFldProperties = 4
Case dbDouble
SetFldProperties = 8
Case dbDate
SetFldProperties = 8
Case dbText
SetFldProperties = 50
Case dbLongBinary
SetFldProperties = 0
Case dbMemo
SetFldProperties = 0
End Select
End Function
Private Sub Command3_Click()
End
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -