Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.9 KiB

  1. Attribute VB_Name = "MiscFunctions"
  2. Option Explicit
  3. Public Sub InsertionSort( _
  4. ByRef u_arrLongs() As Long _
  5. )
  6. Dim intIndex1 As Long
  7. Dim intIndex2 As Long
  8. Dim intCurrent1 As Long
  9. Dim intCurrent2 As Long
  10. Dim intLBound As Long
  11. Dim intUBound As Long
  12. intLBound = LBound(u_arrLongs)
  13. intUBound = UBound(u_arrLongs)
  14. For intIndex1 = intLBound + 1 To intUBound
  15. intCurrent1 = u_arrLongs(intIndex1)
  16. For intIndex2 = intIndex1 - 1 To intLBound Step -1
  17. intCurrent2 = u_arrLongs(intIndex2)
  18. If (intCurrent2 > intCurrent1) Then
  19. u_arrLongs(intIndex2 + 1) = intCurrent2
  20. Else
  21. Exit For
  22. End If
  23. Next
  24. u_arrLongs(intIndex2 + 1) = intCurrent1
  25. Next
  26. End Sub
  27. Public Function GetLongArray( _
  28. ByRef i_vntArray As Variant _
  29. ) As Long()
  30. Dim intArray() As Long
  31. Dim intIndex As Long
  32. Dim intBase As Long
  33. Dim intUBound As Long
  34. ReDim intArray(UBound(i_vntArray) - LBound(i_vntArray))
  35. intBase = LBound(i_vntArray)
  36. intUBound = UBound(i_vntArray) - LBound(i_vntArray)
  37. For intIndex = 0 To intUBound
  38. intArray(intIndex) = i_vntArray(intBase + intIndex)
  39. Next
  40. GetLongArray = intArray
  41. End Function
  42. Public Function CollectionContainsKey( _
  43. ByRef i_col As Collection, _
  44. ByVal i_strKey As String _
  45. )
  46. On Error GoTo LErrorHandler
  47. i_col.Item (i_strKey)
  48. CollectionContainsKey = True
  49. Exit Function
  50. LErrorHandler:
  51. CollectionContainsKey = False
  52. End Function
  53. Public Function FormatTime( _
  54. ByVal i_dtmT0 As Date, _
  55. ByVal i_dtmT1 As Date _
  56. )
  57. Dim dtmDelta As Date
  58. FormatTime = Format(i_dtmT0, "Long Time") & " to " & Format(i_dtmT1, "Long Time") & ": "
  59. dtmDelta = i_dtmT1 - i_dtmT0
  60. FormatTime = FormatTime & _
  61. Hour(dtmDelta) & " hr " & _
  62. Minute(dtmDelta) & " min " & _
  63. Second(dtmDelta) & " sec"
  64. End Function