-
I have asked this a few times before, but i still dont get it..
Im using this to create a button at run time
Code:
Set Boton = Me.Controls.Add("VB.CommandButton", "Boton" & Index)
But, i dont create only one, i create several buttons, if i create one, just one, and use this
Code:
Private Sub Boton_Click()
Boton.Caption = "hi"
End Sub
It works fine, but when i create another button, and i want to use the first one, all the methods to that button cease to work. How can i make the methots to work on every button i create?
Thanks!
-
One way I do this is to place a control on the form with index 0 (this can be invisible to start with if you don't need any).
Then when you need to add a new one use
load control.
where control is the name of the control to reproduce.
use unload to get rid of them
Hope this helps,
regards
Chtis
-
You can't create controlarrays at runtime, although you can create an array of controls, but to recieve the events of them you need to make wrapper classes for them. If you need to create a fixed amount of controls, you could also set to separate controls with withevents.
-
Thanks!!!
The load worked great!!!!