If you want to add a CommandButton, at runtime, use this code.
Code:Private Sub Command1_Click()
Controls.Add "VB.CommandButton", "Command1"
Me!Command1.Move 0, 0
Me!Command1.Caption = "My Button"
Me!Command1.Visible = True
End Sub
Printable View
If you want to add a CommandButton, at runtime, use this code.
Code:Private Sub Command1_Click()
Controls.Add "VB.CommandButton", "Command1"
Me!Command1.Move 0, 0
Me!Command1.Caption = "My Button"
Me!Command1.Visible = True
End Sub
clever, meg - much better than mine! :)
pause while I file it away for future reference...
Keep in mind, this only works in VB6. If you do not have VB6, you can always load them from a Control Array, so you need at least 1 instance of it on the Form and make sure that the Index is set to 0.
Code:Private Sub cmdButton_Click()
Load Comand1(1)
Command1(1).Move 0, 0
Command1(1).Caption = "My Button"
Command1(1).Visible = True
End Sub
thanxs all for the replay, now i can go 2 sleep......at last
why - what's your time there?
It's pretty confusing when you have so many people in so many different time zones.
yeah, it gets tricky after a while, but if you get your TZ settings on your profile right, it's not so bad. however, when my outlook inbox says that I received the notification at 3 in the morning I get confused then when the thread says it was a different time! :confused:
Thats right guys, the same thing in here too
Hmmm. pretty good you guys but I dont know what kind of program you want but if you want a button to appear when some one else clicks another button (or does anything else) then
Private Sub Form_load()
Command1.visible=false
end sub
Private Sub Command2_click()
Command2.visible = true
end sub
THATS THE CHEAP WAY TO DO IT BUT IT TAKES LESS CODE!
IF YOU CAN'T DO IT, FIND A WAY AROUND IT!
But that way, you have already created it. In my method above, you create it from scratch.
er...nitrolic2...if you make command2 visible when you click on it you can't click on it - invisible objects don't receive events.