Эта две функции должны приблизить вас к тому, что вы хотите. Первый использует цифры и буквы. Второй только буквы. MaxChar - это количество букв, которое вы хотите использовать с использованием шкалы 01234567890ABCDEFGHIGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. Альфа не использует только от 0 до 9.
Public Function PackNumber(ByVal Value As Long, ByVal MaxChar As Integer, ByRef IsNeg As Boolean) As String
Dim CurValue As Currency
Dim CharValue As Integer
Dim sPacked As String
If Sgn(n) = -1 Then
IsNeg = True
CurValue = -Value
Else
IsNeg = False
CurValue = Value
End If
sPacked = ""
Do Until Abs(CurValue) <= MaxChar
CharValue = MaxChar * ((CurValue / MaxChar) - Int(CurValue / MaxChar))
CurValue = Int(CurValue / MaxChar)
If CharValue < 10 Then
sPacked = CharValue & sPacked
ElseIf CharValue <= 36 Then
sPacked = Chr(55 + CharValue) & sPacked
Else
sPacked = Chr(60 + CharValue) & sPacked
End If
Loop
CharValue = CurValue
If CharValue < 10 Then
sPacked = CStr(CharValue) & sPacked
ElseIf CharValue <= 36 Then
sPacked = Chr(55 + CharValue) & sPacked
Else
sPacked = Chr(60 + CharValue) & sPacked
End If
PackNumber = sPacked
End Function
Альфа-функция
Public Function PackNumberAlphaOnly(ByVal Value As Long, ByVal MaxChar As Integer, ByRef IsNeg As Boolean) As String
Dim CurValue As Currency
Dim CharValue As Integer
Dim sPacked As String
If Sgn(Value) = -1 Then
IsNeg = True
CurValue = -Value
Else
IsNeg = False
CurValue = Value
End If
sPacked = ""
Do Until Abs(CurValue) <= MaxChar
CharValue = MaxChar * ((CurValue / MaxChar) - Int(CurValue / MaxChar))
CurValue = Int(CurValue / MaxChar)
If CharValue <= 26 Then
sPacked = Chr(65 + CharValue) & sPacked
Else
sPacked = Chr(70 + CharValue) & sPacked
End If
Loop
CharValue = CurValue
If CharValue <= 26 Then
sPacked = Chr(65 + CharValue) & sPacked
Else
sPacked = Chr(70 + CharValue) & sPacked
End If
PackNumberAlphaOnly = sPacked
End Function