Results 1 to 3 of 3

Thread: Having the computer pick one of two or more numbers.

  1. #1

    Thread Starter
    Lively Member dubae524's Avatar
    Join Date
    Jun 2001
    Location
    Currently on this Super Star Destroyer being telekinetically strangled to death by Darth Vader
    Posts
    78

    Question Having the computer pick one of two or more numbers.

    Excuse me, how do you use the random number generator to choose which of 2 or more numbers to choose?

    For example, I want the computer to pick either 2 or 67. No other number. Just those two. Is it possible that any of you can help me? Thanks.
    Last edited by dubae524; Jul 17th, 2001 at 09:37 PM.
    - Justin Patrick Butler

    Comme je trouve. "As I find."
    - Butler family quote

    Beneficia sumptos procul superant. "The benefits far exceed the costs."
    - Myself

  2. #2
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    on a form with a label named Label1 and a button named command1 place this code

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. Dim intRand As Integer
    5.  
    6. Randomize
    7.  
    8. intRand = Int((2 * Rnd) + 1)
    9.  
    10. Select Case intRand
    11.    
    12.     Case Is = 1
    13.         Label1.Caption = "2"
    14.    
    15.    
    16.     Case Is = 2
    17.         Label1.Caption = "67"
    18.        
    19. End Select
    20.    
    21.    
    22. End Sub

    it works well but of coarse with only 2 numbers to generate it returns a lot of the same hits frequently

    just change the code in the select case statement to do what you want to occur if its 2 or 67

  3. #3

    Thread Starter
    Lively Member dubae524's Avatar
    Join Date
    Jun 2001
    Location
    Currently on this Super Star Destroyer being telekinetically strangled to death by Darth Vader
    Posts
    78

    Talking

    I never thought of that! Thanks for your input!
    - Justin Patrick Butler

    Comme je trouve. "As I find."
    - Butler family quote

    Beneficia sumptos procul superant. "The benefits far exceed the costs."
    - Myself

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