Results 1 to 2 of 2

Thread: random command & opening outside programs

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Question

    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!

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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"
    Iain, thats with an i by the way!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width