Results 1 to 40 of 40

Thread: Random number if = True

Hybrid View

  1. #1
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Random number if = True

    Again, Lucky should be declared something other than Byte. It needs to be declared Integer or Long to prevent overflowing. Plus he's working with numbers larger than 255. And you should never use IIF(). We proved this a while ago in one of these threads, but it is the slowest If statement of them all. Very slow infact. Although it doesnt matter in his program or yours, it should never be used in something like Loops or Timers, especially when making a game.

  2. #2
    Addicted Member
    Join Date
    May 2005
    Posts
    168

    Re: Random number if = True

    Hi,

    Jacob:

    Lucky can be byte since it is a checkbox value 0-2. <g> LuckyNum is an integer. -32767...32767 (in my example at least) <g>

    Variants are intrinsically slower but to the point of NEVER using them LOL.

    Have a good one!
    BK

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Random number if = True

    Quote Originally Posted by Black__Knight
    Hi,

    Jacob:

    Lucky can be byte since it is a checkbox value 0-2. <g> LuckyNum is an integer. -32767...32767 (in my example at least) <g>

    Variants are intrinsically slower but to the point of NEVER using them LOL.

    Have a good one!
    BK
    Not according to his code, unless he has many typos going. If I were him, I change the variables in bold to LuckyNum:

    VB Code:
    1. Dim Lucky As Byte '<----- This will be fine if the numbers gonna be between 0-255
    2. Dim LuckyNum As Variant '<----- Never use variants. I would use Long in this case.
    3.  
    4. If Lucky = 1 Then
    5.  
    6.  [b]Lucky[/b] = 258 + 2 + 4 - 1 'Change this to LuckyNum
    7.  
    8. Else
    9.  
    10.  [b]Lucky[/b] = 258 - 2 - 4 + 1 'Change this to LuckyNum
    11.  
    12. End If
    13.  
    14. LuckyNum = Lucky 'Comment this line out
    15.  
    16. Print format(LuckyNum, "000" ' If true Print will show 263 otherwise it will go back to number 258

  4. #4

    Thread Starter
    Hyperactive Member High Octane's Avatar
    Join Date
    Aug 2003
    Location
    Texas
    Posts
    290

    Re: Random number if = True

    Black__Knight, I liked your code... look like it work good... But its like a countdown from 258 and minus...

    Jacob Roman

    LuckyNum = Lucky This string retrieve information from lucky so it can print on the form like this below

    Print format(LuckyNum, "000")

    It doesn't require to do this, I could simply add Lucky inside the parenthesis instead of LuckyNum. But I did that to avoid confusion, just having habit of organizing codes.

    Guys, sorry for so many confusions.... here what I am going to ask... is it possible to get number to fluxuating when the variable is true based on delay time or timeinterval then it stops when variable is not true?

    for example:

    if lucky = 0 then 258 labeled on form (stays there no changes)
    if lucky = 1 then 266 (.5 ms) 271 (.5 ms) 264 (.5ms) and repeats....
    if lucky = 0 (again) 258 labeled again and (stays there no change)

    of course with cls and auto redraw so it wont creates list downs, but overlapiing.

    Let me know
    High Octane

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