random number help

Discussion in 'Archives' started by superman1478, May 16, 2007.

random number help
  1. Unread #1 - May 16, 2007 at 3:58 PM
  2. superman1478
    Joined:
    Jan 21, 2007
    Posts:
    701
    Referrals:
    2
    Sythe Gold:
    0

    superman1478 Apprentice

    random number help

    This code is what i'm using to display a random number for my auto alcher. Someone suggested that i have it display numbers with decimals,and i cant seem to get it to do that.

    Code:
    Private Sub Timer1_Timer()
    Randomize
    text1.Text = Int(Rnd * (6 - 2 + 1) + 2)
    End Sub
    
    How do i have this display decimals, not just whole numbers?
     
  3. Unread #2 - May 16, 2007 at 4:01 PM
  4. joewnn
    Joined:
    Apr 21, 2005
    Posts:
    1,500
    Referrals:
    0
    Sythe Gold:
    0

    joewnn Guru
    Banned

    random number help

    One thing, instead of 6 - 2 + 1 why not just 5? It is inside () so it would be the same as rnd * (5) + 2

    edit: instead of using a whole number try like 5.3235 or something...
     
  5. Unread #3 - May 16, 2007 at 4:38 PM
  6. superman1478
    Joined:
    Jan 21, 2007
    Posts:
    701
    Referrals:
    2
    Sythe Gold:
    0

    superman1478 Apprentice

    random number help

    The reason i have the +1 there is because is place of the 6 i have cmdinterval.text.

    I have tried doing things like

    Code:
    Text1.Text = Int(Rnd * (6.3235 - 2.505 + 1) + 2.505)
    
     
  7. Unread #4 - May 16, 2007 at 4:45 PM
  8. joewnn
    Joined:
    Apr 21, 2005
    Posts:
    1,500
    Referrals:
    0
    Sythe Gold:
    0

    joewnn Guru
    Banned

    random number help

    Well using Int changes it to a whole number.. so just remove int. If you need, you can find a different function that won't remove the decimal.
     
  9. Unread #5 - May 16, 2007 at 5:36 PM
  10. superman1478
    Joined:
    Jan 21, 2007
    Posts:
    701
    Referrals:
    2
    Sythe Gold:
    0

    superman1478 Apprentice

    random number help

    That solves my problem, thanks.
     
< How do bears have sex. | Selling AWSOME f2p pure :o >

Users viewing this thread
1 guest


 
 
Adblock breaks this site