| 0. | 'GetTickCount Declaration |
| 1. | Private Declare Function GetTickCount Lib "Kernel32" () As Long |
| 2. | 'The GetTickCount function retrieves the number of |
| 3. | 'milliseconds that have elapsed since the system was started. |
| 4. | 'It is limited to the resolution of the system timer. |
| 5. | 'http://msdn.microsoft.com/library/psdk/sysmgmt/time_8wz8.htm |
| 6. | |
| 7. | |
| 8. | Dim aNames(50) As String |
| 9. | Dim aTimes(50) As Long |
| 10. | Dim maxTimes As Long |
| 11. | Dim allNames As String |
| 12. | |
| 13. | Public Sub setTime(ByVal name As String) |
| 14. | If InStr(allNames, name + ",") > 0 Then |
| 15. | For x = 0 To maxTimes |
| 16. | If aNames(x) = name Then |
| 17. | aTimes(x) = GetTickCount() |
| 18. | Exit For |
| 19. | End If |
| 20. | Next |
| 21. | Else |
| 22. | maxTimes = maxTimes + 1 |
| 23. | aNames(maxTimes) = name |
| 24. | aTimes(maxTimes) = GetTickCount() |
| 25. | allNames = allNames + name + "," |
| 26. | End If |
| 27. | End Sub |
| 28. | |
| 29. | Public Function getTime(ByVal name As String) As Long |
| 30. | If InStr(allNames, name) > 0 Then |
| 31. | For x = 0 To maxTimes |
| 32. | If aNames(x) = name Then |
| 33. | getTime = aTimes(x) |
| 34. | Exit For |
| 35. | End If |
| 36. | Next |
| 37. | Else |
| 38. | getTime = 0 |
| 39. | End If |
| 40. | End Function |
| 41. | |
| 42. | Public Function getNow() As Long |
| 43. | getNow = GetTickCount() |
| 44. | End Function |
| 45. | |
| 46. | Public Function formatTime(ByVal lTime1 As Long) As String |
| 47. | 'parts borrowed from MSDN |
| 48. | |
| 49. | Dim hour As Integer, minute As Integer, second As Integer |
| 50. | Dim raw |
| 51. | raw = lTime1 \ 1000 |
| 52. | hour = raw \ 3600 |
| 53. | raw = raw - (hour * 3600) |
| 54. | minute = raw \ 60 |
| 55. | raw = raw - (minute * 60) |
| 56. | second = raw |
| 57. | If minute < 10 Then |
| 58. | If second < 10 Then |
| 59. | sReturn = hour & ":0" & minute & ":0" & second |
| 60. | Else |
| 61. | sReturn = hour & ":0" & minute & ":" & second |
| 62. | End If |
| 63. | Else |
| 64. | If second < 10 Then |
| 65. | sReturn = hour & ":" & minute & ":0" & second |
| 66. | Else |
| 67. | sReturn = hour & ":" & minute & ":" & second |
| 68. | End If |
| 69. | End If |
| 70. | formatTime = sReturn |
| 71. | End Function |