Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Modules (VBA Coding) FAQ


Calculate milliseconds by rfoye
Posted: 16 Aug 07

I don't know about you, but I get slowed down with timer calls where you have to specify the number of ticks or milliseconds. Here is a bit of code I wrote where you enter the Time Unit (Minutes, Seconds) and the number of those units that you want to wait.


Public Function fMillis(lngVal As Long, stUnit As String) As Long
    ' This function allows you to quickly understand the time span
    ' involved, rather than having to enter the number of
    ' milliseconds or calculate how many seconds or minutes are
    ' represented by the millisecond value.
    ' You can type the complete time unit, or an abbreviation:
    '   Minutes, Minute, Min, M, Seconds, Second, Sec, S
    ' Examples: fMillis(10, "Seconds"), fMillis(5,"Minutes")
    ' If the clocking speed of your processor is different,
    ' you can change the constant cMilli to the number of ticks
    ' per second for your machine.
    Dim secs As Long
    Const cMilli As Long = 1000
    stUnit = Left$(stUnit, 1)
    Select Case stUnit
        Case "M"
            secs = lngVal * 60
        Case "S"
            secs = lngVal
        Case Else
            secs = 0
    End Select
    fMillis = secs * cMilli
End Function

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close