|
-
Nov 15th, 2000, 08:04 PM
#1
Thread Starter
Registered User
Hello everyone, i am making an experiment, and i need to send this to 3 other people. But when i make an .exe the program doesnt' even work correctly....for instance, here is my code:
Code:
Private Sub Command1_Click()
Dim x As Single
Dim i As Long
x = Timer
For i = 0 To 100000000
i = i + 1
Next i
x = Timer - x
MsgBox "The loop took " & x & " seconds."
End Sub
this will time a loop and display how long it took to cycle threw it...in Run time, i click it it says somtimes 6 seconds somtimes 7, and when i make an .exe it says .04984 or 1 second, whats up? is there anyway for me to fix it so it wont' do this?
Thanks for listening 
-
Nov 15th, 2000, 08:47 PM
#2
Member
What did you want? Compiled code will always run a lot faster then when it is run from the IDE. Your code is probably timing correctly.
-
Nov 15th, 2000, 08:53 PM
#3
Doesn't do what? If you want it to show only whole numbers you can format the result.
Code:
Number=Format(Number,"0")
Of course this will round up so .5 and up is 1 and .4 and below is 0.
-
Nov 15th, 2000, 09:05 PM
#4
Thread Starter
Registered User
Oh so what would be a reasonalbe number?
my number is already huge....
100000000
How much bigger should i make it so when i run the program....on other computers, say the person has a processor that is a 700, i want it to at least break 1 when its timed, or is that reasonable for the loop to go so fast?
-
Nov 15th, 2000, 09:16 PM
#5
Member
For i = 0 To 100000000
i = i + 1
Next i
Take out the i = i + 1 part. You are actually counting by 2's. If not enough yet then either increase the number or put another loop in to slow it down.
Dim i as long
Dim j as long
For i = 0 To 100000000
for j = 1 to 100
next j
Next i
this is the same as counting to 100, 100000000 times
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
|