Inmiddels heb ik een sheet waar in de juiste opmaak een frame gevuld wordt.
(Deze code kan verbeterd worden, maar dat doet nu niet ter zaken).
Nu wil ik als ik op een knop druk dat er een functie uitgevoerd wordt. Hier begint het probleem echter al. Dit werkt niet.
Het hele frame wordt dynamisch opgebouwd.
2 vragen zijn nu.
1. Hoe kan ik met clear een functie krijgen
2. Hoe kan ik vanuit die functie de controls die in een andere functie zijn gedefinieerd "setten", bijvoorbeeld de naam of de value?
Totale code:
(Deze code kan verbeterd worden, maar dat doet nu niet ter zaken).
Nu wil ik als ik op een knop druk dat er een functie uitgevoerd wordt. Hier begint het probleem echter al. Dit werkt niet.
Het hele frame wordt dynamisch opgebouwd.
2 vragen zijn nu.
1. Hoe kan ik met clear een functie krijgen
2. Hoe kan ik vanuit die functie de controls die in een andere functie zijn gedefinieerd "setten", bijvoorbeeld de naam of de value?
Totale code:
Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
| Global BaseFrame As Frame Global Group_Box_01 As Frame Global Group_Box_02 As Frame Global Group_Box_03 As Frame Global Label_01 As Control Global Label_02 As Control Global Radio_Button_01 As Control Sub Metric_Chooser() Dim Commandbutton_Clear As Control Dim Commandbutton_Submit As Control Dim Radio_Button_02 As Control Dim Radio_Button_03 As Control Dim Radio_Button_04 As Control Dim Radio_Button_05 As Control Dim Radio_Button_06 As Control Dim Radio_Button_07 As Control Dim Radio_Button_08 As Control Dim Universal_Dropdown As Control Dim Date_Chooser_01 As Control Dim Date_Chooser_02 As Control ' Create Frame for Metric Chooser Set BaseFrame = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Frame.1", Link:=False, _ DisplayAsIcon:=False, Left:=10, Top:=10, _ Width:=490, Height:=230).Object With BaseFrame .Object.Caption = "Metric Requirement - Chooser" .Name = "BaseFrame" .Enabled = True End With Set Commandbutton_Clear = BaseFrame.Controls.Add("Forms.CommandButton.1", "Clear", True) With Commandbutton_Clear .Left = 330 .Top = 195 .Width = 70 .Height = 20 .Name = "Clear" .Caption = "Clear" .Visible = True .Enabled = True End With Set Commandbutton_Submit = BaseFrame.Controls.Add("Forms.CommandButton.1", "Submit", True) With Commandbutton_Submit .Left = 410 .Top = 195 .Width = 70 .Height = 20 .Name = "Submit" .Caption = "Submit" End With Set Group_Box_01 = BaseFrame.Controls.Add("Forms.Frame.1") With Group_Box_01 .Left = 170 .Top = 10 .Width = 150 .Height = 175 .Visible = True .Object.Caption = "Select Time Frame" End With Set Group_Box_02 = BaseFrame.Controls.Add("Forms.Frame.1") With Group_Box_02 .Left = 330 .Top = 10 .Width = 150 .Height = 175 .Visible = True .Object.Caption = "Select Metric Type" End With Set Group_Box_03 = BaseFrame.Controls.Add("Forms.Frame.1") With Group_Box_03 .Left = 10 .Top = 10 .Width = 150 .Height = 175 .Visible = True .Object.Caption = "Select Time Period" End With 'Set Group_Box_01 = BaseFrame.Controls.Add("Frame") Set Radio_Button_01 = Group_Box_03.Controls.Add("Forms.OptionButton.1") With Radio_Button_01 .Name = "Radio_Button" .Caption = "Day" .Left = 15 .Top = 10 .Width = 120 .Height = 20 .Value = True .Visible = True End With Set Radio_Button_02 = Group_Box_03.Controls.Add("Forms.OptionButton.1") With Radio_Button_02 .Left = 15 .Top = 35 .Caption = "Week" .Width = 120 .Height = 20 .Visible = True End With Set Radio_Button_03 = Group_Box_03.Controls.Add("Forms.OptionButton.1") With Radio_Button_03 .Left = 15 .Top = 60 .Caption = "Month" .Width = 120 .Height = 20 .Visible = True End With Set Radio_Button_04 = Group_Box_03.Controls.Add("Forms.OptionButton.1") With Radio_Button_04 .Left = 15 .Top = 85 .Caption = "Quarter" .Width = 120 .Height = 20 .Visible = True End With Set Radio_Button_05 = Group_Box_03.Controls.Add("Forms.OptionButton.1") With Radio_Button_05 .Left = 15 .Top = 110 .Caption = "Year" .Width = 120 .Height = 20 .Visible = True End With Set Radio_Button_06 = Group_Box_03.Controls.Add("Forms.OptionButton.1") With Radio_Button_06 .Left = 15 .Top = 135 .Caption = "Period" .Width = 120 .Height = 20 .Visible = True End With Set Radio_Button_07 = Group_Box_02.Controls.Add("Forms.OptionButton.1") With Radio_Button_07 .Left = 15 .Top = 10 .Caption = "Units per Manhour" .Width = 120 .Height = 20 .Visible = True End With Set Radio_Button_08 = Group_Box_02.Controls.Add("Forms.OptionButton.1") With Radio_Button_08 .Left = 15 .Top = 35 .Caption = "Costs per Unit" .Width = 120 .Height = 20 .Visible = True End With ' Create all specific drop downs in middel group frame Group_Box_01 Set Label_01 = Group_Box_01.Controls.Add("Forms.Label.1") With Label_01 .Left = 15 .Top = 20 .Caption = "Week:" 'Week,Month,Quarter,Year, Start Date .Width = 120 .Height = 20 .Visible = True End With Set Label_02 = Group_Box_01.Controls.Add("Forms.Label.1") With Label_02 .Left = 15 .Top = 70 .Caption = "End Date:" 'End Date .Width = 120 .Height = 20 .Visible = True End With Set Universal_Dropdown = Group_Box_01.Controls.Add("Forms.ComboBox.1") With Universal_Dropdown .Left = 15 .Top = 35 .Width = 120 .Height = 20 .Visible = True End With Set Date_Chooser_01 = Group_Box_01.Controls.Add("MSComCtl2.DTPicker.2") With Date_Chooser_01 .Left = 15 .Top = 35 .Width = 120 .Height = 20 .Visible = True End With Set Date_Chooser_02 = Group_Box_01.Controls.Add("MSComCtl2.DTPicker.2") With Date_Chooser_02 .Left = 15 .Top = 85 .Width = 120 .Height = 20 .Visible = True End With BaseFrame.Select Selection.Verb Verb:=xlPrimary End Sub Function Clear_Function() Label_01.Value = "Text" End Function |