Here’s another alternative (old VB6/VBA – not VB.Net syntax).
KEY SUGGESTION: the “_” characters are “continuation lines”. I honestly don’t think you want them in most of the places you’re using them.
IMHO…
Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private startTime, endTime As Long
Private Function elapsedTime(t1, t2 As Long) As Long
elapsedTime = t2 - t1
End Function
Public Function MyTest()
startTime = Now
' << do stuff >>
endTime = Now
MsgBox "Elapsed time=" & elapsedTime(startTime, endTime)
End Function
Private Sub Command1_Click()
Call MyTest
End Sub
edited.
1
solved Measuring query processing time in Microsoft Access