Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function that makes timer values easy (milliseconds)

Status
Not open for further replies.

rfoye

Programmer
Oct 15, 2004
40
US
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.
Code:
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

-------------------
Rob Foye
Database Management
Regions Bank
 




Good for you.

Put it in an FAQ.

Skip,

[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top