|
-
Jun 5th, 2000, 07:13 PM
#1
Thread Starter
Lively Member
Aquiring new knownledge about creating controls at run time, I would like to them to share a common event-procedure.
Does anyone know how to do this? Look at my pseudo to see what I'm looking for.
Code:
Dim myControls(100) As objects
Sub MakeTheControls()
Set myControls(0) = Controls.Add(...)
Set myControls(1) = Controls.Add(...)
...
End Sub
Sub CommonEvent(AString As String)
'AString is an identifier that i can use in the following:
Select Case AString
Case "my1stcontrol": ...
Case "my2ndcontrol": ...
...
End Select
End Sub
-
Jun 5th, 2000, 07:36 PM
#2
Member
What you're talking about is a control array. Control arrays share the same event procedure:
Sub Control_Click(Index as Integer)
'Test for which control was clicked by its index
End Sub
I beleive that you have to add 1 control at design time and then use the 'Load' statement at run time. I don't have a good example to show you, but I know it's on my computer somewhere. If I find it, I'll email it to you.
Hope this helps,
Dan
-
Jun 6th, 2000, 08:12 AM
#3
Here's an example. Make a Contrtol called MyControl and place the following code into a CommandButton. Make sure that the Index property to MyControl is set to 0.
Code:
Load MyControl(1)
MyControl(1).Move 0, 0
MyControl(I).Visible = True
-
Jun 6th, 2000, 06:46 PM
#4
Thread Starter
Lively Member
You don't by any way know how to create an control array in VBA, do you? You can't do it the way you do it in VB5/6. If you can at all.
-
Jun 7th, 2000, 03:39 AM
#5
No, I don't think that method would work in VBA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|