Untitled
unknown
plain_text
3 months ago
1.8 kB
8
Indexable
Function FormatTime(t As String) As String
Dim c As String
Dim dp As Long
Dim h As String
Dim m As String
c = Replace(t, ":", ".")
dp = InStr(c, ".")
If dp = 0 Then
h = c
m = "00"
Else
h = Left(c, dp - 1)
m = Mid(c, dp + 1)
End If
If Len(m) = 1 Then
m = m & "0"
End If
If Len(m) > 2 Then
m = Left(m, 2)
End If
If Len(h) < 2 Then
h = "0" & h
End If
FormatTime = h & ":" & m
End Function
Function AddOneHour(t As String) As String
Dim p() As String
Dim h As Integer
Dim m As Integer
Dim hs As String
Dim ms As String
p = Split(t, ":")
If UBound(p) < 1 Then
AddOneHour = t
Exit Function
End If
h = CInt(p(0))
m = CInt(p(1))
h = h + 1
If h >= 24 Then
h = h - 24
End If
hs = CStr(h)
ms = CStr(m)
If Len(hs) < 2 Then
hs = "0" & hs
End If
If Len(ms) < 2 Then
ms = "0" & ms
End If
AddOneHour = hs & ":" & ms
End Function
Function SortDictKeys(dict As Object) As Variant
Dim n As Long
Dim k() As String
Dim i As Long
Dim j As Long
Dim tmp As String
Dim kk As Variant
n = dict.Count
If n = 0 Then
SortDictKeys = Array()
Exit Function
End If
ReDim k(0 To n - 1)
i = 0
For Each kk In dict.Keys
k(i) = CStr(kk)
i = i + 1
Next kk
For i = 0 To n - 2
For j = 0 To n - 2 - i
If k(j) > k(j + 1) Then
tmp = k(j)
k(j) = k(j + 1)
k(j + 1) = tmp
End If
Next j
Next i
SortDictKeys = k
End FunctionEditor is loading...
Leave a Comment