|
-
Jul 8th, 2005, 06:11 PM
#1
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.
-
Jul 8th, 2005, 06:19 PM
#2
Addicted Member
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
-
Jul 8th, 2005, 06:21 PM
#3
Re: Random number if = True
 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:
Dim Lucky As Byte '<----- This will be fine if the numbers gonna be between 0-255
Dim LuckyNum As Variant '<----- Never use variants. I would use Long in this case.
If Lucky = 1 Then
[b]Lucky[/b] = 258 + 2 + 4 - 1 'Change this to LuckyNum
Else
[b]Lucky[/b] = 258 - 2 - 4 + 1 'Change this to LuckyNum
End If
LuckyNum = Lucky 'Comment this line out
Print format(LuckyNum, "000" ' If true Print will show 263 otherwise it will go back to number 258
-
Jul 8th, 2005, 07:14 PM
#4
Thread Starter
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|