Dim c As String
Dim b() As Byte
c = ""
a = "546789908887766"
b = a
For j = 0 To UBound(b)
If (j > (UBound(b) - 18)) And (j Mod 2) = 1 Then
Else
c = c & b(j)
End If
有个简单的办法,可以转化为别的进制,下面是一个转化为3进制的例子,位数不足用0补齐,结果应该是唯一的:
Private Sub Command1_Click()
MsgBox dectothird(String(15, "9"))
End Sub
Function dectothird(ByVal hugenum As String) As String ' trans hugenum to third
Do While Not Val(hugenum) < 3
dectothird = Val(Right(hugenum, 2)) Mod 3 & dectothird
hugenum = third(hugenum) 'devide hugenum by 3
Loop
dectothird = Val(hugenum) & dectothird
dectothird = Right(String(36, "0") & dectothird, 36)
End Function
Function third(ByVal x As String) As String 'get third of x
Dim temp As String, result() As String
temp = x
Dim i As Long
ReDim result(1 To Len(temp)) As String
result(1) = Mid(temp, 1, 1) \ 3
Mid(temp, 1, 1) = Val(Mid(temp, 1, 1) Mod 3)
For i = 2 To Len(x)
result(i) = (Val(Mid(temp, i, 1)) + Val(Mid(temp, i - 1, 1)) * 10) \ 3
Mid(temp, i, 1) = (Val(Mid(temp, i, 1)) + Val(Mid(temp, i - 1, 1)) * 10) Mod 3
Next
third = Join(result, "")
If Left(thirdh, 1) = "0" Then third = Right(third, Len(third) - 1) ' no zero ahead
Erase result
End Function