📄 datawiz.frm
字号:
VERSION 5.00
Begin VB.Form DataWIZ
BorderStyle = 3 'Fixed Dialog
Caption = "数据生成向导(第一步)"
ClientHeight = 5655
ClientLeft = 3090
ClientTop = 1800
ClientWidth = 6615
ControlBox = 0 'False
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5655
ScaleWidth = 6615
ShowInTaskbar = 0 'False
Begin VB.Frame Frame1
BorderStyle = 0 'None
Height = 5655
Left = 0
TabIndex = 0
Top = 0
Width = 6615
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 4200
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 1920
Visible = 0 'False
Width = 1140
End
Begin VB.CommandButton Command2
Caption = "下一步(&N)"
Enabled = 0 'False
Height = 375
Index = 1
Left = 5400
TabIndex = 14
Top = 5160
Width = 975
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Index = 0
Left = 3720
TabIndex = 13
Top = 5160
Width = 975
End
Begin VB.ListBox List2
Height = 1680
Left = 3960
TabIndex = 11
Top = 3000
Width = 2415
End
Begin VB.CommandButton Command1
Caption = "<<"
Height = 300
Index = 3
Left = 3240
TabIndex = 10
Top = 4440
Width = 375
End
Begin VB.CommandButton Command1
Caption = "<"
Height = 300
Index = 2
Left = 3240
TabIndex = 9
Top = 3960
Width = 375
End
Begin VB.CommandButton Command1
Caption = ">>"
Height = 300
Index = 1
Left = 3240
TabIndex = 8
Top = 3480
Width = 375
End
Begin VB.CommandButton Command1
Caption = ">"
Height = 300
Index = 0
Left = 3240
TabIndex = 7
Top = 3000
Width = 375
End
Begin VB.ListBox List1
Height = 1680
Left = 240
TabIndex = 6
Top = 3000
Width = 2535
End
Begin VB.ComboBox Combo1
Height = 300
Left = 240
Style = 2 'Dropdown List
TabIndex = 4
Top = 2160
Width = 2415
End
Begin VB.Frame Frame2
Height = 1215
Left = 360
TabIndex = 1
Top = 360
Width = 2775
Begin VB.Image Image1
Height = 735
Left = 240
Picture = "DataWIZ.frx":0000
Top = 240
Width = 2205
End
End
Begin VB.Line Line2
BorderColor = &H80000005&
X1 = 120
X2 = 6480
Y1 = 4920
Y2 = 4920
End
Begin VB.Line Line1
BorderWidth = 2
X1 = 120
X2 = 6480
Y1 = 4920
Y2 = 4920
End
Begin VB.Label Label4
Caption = "选定字段(&S):"
Height = 255
Left = 3960
TabIndex = 12
Top = 2760
Width = 1455
End
Begin VB.Label Label3
Caption = "用用字段(&M):"
Height = 255
Left = 240
TabIndex = 5
Top = 2760
Width = 1335
End
Begin VB.Label Label2
Caption = "数据库/表/查询(&T):"
Height = 255
Left = 240
TabIndex = 3
Top = 1920
Width = 2055
End
Begin VB.Label Label1
Caption = "请要生成的数据需要那些字段,请从下列多个表或查询中选择出来:"
Height = 735
Left = 3600
TabIndex = 2
Top = 720
Width = 2655
End
End
End
Attribute VB_Name = "DataWIZ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Combo1_Click()
List1.Clear
List2.Clear
Dim Fd As Field
Dim TbName As String
For Each Fd In Data1.Database.TableDefs(Combo1.ListIndex).Fields
List1.AddItem Fd.Name
If Combo1.ListIndex = 16 Then
'校验字段的合法性
' Debug.Print Fd.Name & " 类型:" & Fd.Type & " 宽度:" & Fd.Size
End If
Next
If List1.ListCount <> 0 Then
Command1(0).Enabled = True
List1.Selected(0) = True
Else
Command1(0).Enabled = False
End If
TbName = List1.Text
End Sub
Private Sub Command1_Click(Index As Integer)
On Error GoTo b0:
Dim i As Integer
Select Case Index
Case 0 '逐个增加
If List2.ListCount = 1 Then Command1(2).Enabled = True
Command1(1).Enabled = True
Command2(1).Enabled = True
List2.AddItem List1.Text
If List1.ListCount - 1 <> List1.ListIndex Then
List1.Selected(List1.ListIndex + 1) = True
List2.Selected(List2.NewIndex) = True
Else
Command1(0).Enabled = False
Command1(1).Enabled = False
Command1(3).Enabled = True
End If
Case 1 '全部增加
For i = 0 To List1.ListCount - 1
List2.AddItem List1.Text
If List1.ListCount - 1 <> i Then
List1.ListIndex = List1.ListIndex + 1
List2.Refresh
Else
List1.ListIndex = 0
List2.ListIndex = 0
Command1(0).Enabled = False
Command1(1).Enabled = False
Command1(2).Enabled = True
Command1(3).Enabled = True
Command2(1).Enabled = True
Exit For
End If
Next
Case 2 '逐个移除
If List2.ListCount = 1 Then Command1(2).Enabled = False
Command1(0).Enabled = True
' List2.AddItem List3.Text
List2.RemoveItem List2.ListIndex
If List2.ListCount > 0 Then
List2.Selected(List2.ListIndex + 1) = True
Else
List1.ListIndex = 0
Command2(1).Enabled = False
Command1(1).Enabled = True
Command1(3).Enabled = False
End If
' List1.Selected(List1.NewIndex) = True
Case 3 '全部移除
List2.Clear
Command1(0).Enabled = True
Command1(1).Enabled = True
Command1(2).Enabled = False
Command1(3).Enabled = False
Command2(1).Enabled = False
List1.ListIndex = 0
b0:
End Select
End Sub
Private Sub Command2_Click(Index As Integer)
Select Case Index
Case 0 ' 取消
Unload Me
Cela = False
Exit Sub
Case 1 ' 下一步
Me.Hide
DaTaWiz1.Show vbModal
End Select
End Sub
Private Sub Form_Load()
' Dim NdMd As Database, MdbR As Recordset '全局库名,表名
' Set NdMd = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\Data\Eletricity.Mdb")
' Set MdbR = NdMd.OpenRecordset("用户电费")
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
Dim Tb As TableDef
Data1.DatabaseName = App.Path & "\DATA\ELETRICITY.MDB"
Data1.Refresh
For Each Tb In Data1.Database.TableDefs
Combo1.AddItem Tb.Name
Next
Combo1.ListIndex = 8
Command1(2).Enabled = False
Command1(3).Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -