Const sBaseStr As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx"
Function encoding_number(ByVal number As String) As String
Dim a As Double, b As Long, so As Double, result As String
If Len(number) = 1 Then
encoding_number = Mid(sBaseStr, number + 1, 1)
number = ""
End If
If Len(number) = 0 Then Exit Function
b = Right(number, 1)
a = Left(number, Len(number) - 1)
so = Int(a / 6 + b / 60)
b = (a - so * 6) * 10 + b
result = Mid(sBaseStr, b + 1, 1)
Do While so
a = so
so = Int(so / 60)
b = a - so * 60
result = Mid(sBaseStr, b + 1, 1) & result
Loop
encoding_number = result
End Function
Function decoding_code(ByVal code As String) As String
Dim k As Long, a As Long, result
If Len(code) = 0 Then Exit Function
For k = 1 To Len(code) - 2
result = (result + (InStr(1, sBaseStr, Mid(code, k, 1), vbBinaryCompare) - 1)) * 60
Next k
If Len(code) > 1 Then result = (result + (InStr(1, sBaseStr, Mid(code, Len(code) - 1, 1), vbBinaryCompare) - 1)) * 6
a = InStr(1, sBaseStr, Mid(code, Len(code), 1), vbBinaryCompare) - 1
result = (result + a \ 10) & (a Mod 10)
If Mid(result, 1, 1) = "0" Then result = Mid(result, 2)
decoding_code = result
End Function