-
My first question has to do with the random command, i have 30 command buttons, named Command## (## = any number 1-30. What I want to do is when randomcmd is clicked, it randomly selects 1-30 and performs the action of Command##.click
My second question is how would i open a program through my vb program, say Solitaire or the calculator, just click a button, and the program opens, thanks for your help!
-
Command Buttons.
You will need a control array, if you haven't already got one.
Then do
Code:
private sub randomcmd_click()
Dim i as integer
'find a random number between 1 and 30
Randomize
i = cint(rnd * 29) + 1
'call the click event with the index as the random num.
cmdCommandArray_Click(i)
End Sub
cmdCommandArray_Click(Index As Integer)
Select Case Index
Case = 1
'do something
Case = 2
'do something
'blah blah blah
End Select
Ens Sub
To run a program you will need to use "Shell" or "ShellExecute"