how do i get vba to count upto large numbers

jackal575

New member
Local time
Today, 09:36
Joined
Feb 12, 2005
Messages
8
i am trying to make vba count to a number bigger than 1e10 (1x10^9) can it be done or is it restricted by my system??
 
srry, i found out how to do it now but how can i get vba to measure time in milliseconds? i have been using the timer function until now and it is not accurate enough
 
Have a look at the API call in this attachment
 

Attachments

In the code pane go Insert>Class module. and add the code

Private plngStart As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Public Sub StartTimer()
plngStart = timeGetTime
End Sub

Public Function EndTimer() As Long
EndTimer = (timeGetTime - plngStart)
End Function

save the Module as StopWatch

call the code like:-

Sub test() 'test stopwatch function
Dim intLoop As Integer
Dim SW As New StopWatch
SW.StartTimer
For intLoop = 1 To 100
DoEvents
Next intLoop
Debug.Print SW.EndTimer
End Sub

HTH

Peter
 
thanks for the replies guys but i have another problem :( in this form, i am trying to see how long it takes for the computer to count to like a million five times and get an average. i have tryed to get it working but it doesnt want to. (because im trying to use a constant as a form reference thing) i cant think of another way to do it can u guys help again? thanks for your patience with the noob :)
 

Attachments

Last edited:
try this code behind your form

Code:
Option Compare Database
Option Explicit

Private Declare Function WWindowsStart Lib "WINMM" Alias "timeGetTime" () As Long

Dim lngStart As Long
Dim lngStop As Long
Private Sub Startbutton_Click()
Dim x As Long
Dim y As Integer
For y = 1 To 5
    lngStart = WWindowsStart
    For x = 1 To 1000000
    Next x
    lngStop = WWindowsStart
    Me.Controls("box" & y) = lngStop - lngStart
Next y
Me.Scorebox = (Me.box1 + Me.box2 + Me.box3 + Me.box4 + Me.box5) / 5

End Sub
Private Sub Resetbutton_Click()

Me.Scorebox = Null
Me.box1 = Null
Me.box2 = Null
Me.box3 = Null
Me.box4 = Null
Me.box5 = Null
End Sub

peter
 

Users who are viewing this thread

Back
Top Bottom