Adblock breaks this site

random number help

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

  1. superman1478

    superman1478 Apprentice

    Joined:
    Jan 21, 2007
    Posts:
    701
    Referrals:
    2
    Sythe Gold:
    0
    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?
     
  2. joewnn

    joewnn Guru
    Banned

    Joined:
    Apr 21, 2005
    Posts:
    1,500
    Referrals:
    0
    Sythe Gold:
    0
    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...
     
  3. superman1478

    superman1478 Apprentice

    Joined:
    Jan 21, 2007
    Posts:
    701
    Referrals:
    2
    Sythe Gold:
    0
    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)
    
     
  4. joewnn

    joewnn Guru
    Banned

    Joined:
    Apr 21, 2005
    Posts:
    1,500
    Referrals:
    0
    Sythe Gold:
    0
    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.
     
  5. superman1478

    superman1478 Apprentice

    Joined:
    Jan 21, 2007
    Posts:
    701
    Referrals:
    2
    Sythe Gold:
    0
    random number help

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


 
 
Adblock breaks this site