····
Function StrToNum(ByVal Str As String) As Long '字母转数字
Dim s As String, S1 As String
If Str = "" Then Exit Function
Str = UCase(Str)
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
For i = 1 To Len(Str)
S1 = Mid(Str, i, 1)
If InStr(s, S1) = 0 Then Crazy_Num = -1: Exit Function
StrToNum = StrToNum + InStr(s, S1) * 26 ^ (Len(Str) - i)
Next
End Function
···
···
Function NumToStr(ByVal Num As Long) As String '数字转字母
Dim M As Long
If Num < 1 Then Exit Function
Do
M = Num Mod 26
If M = 0 Then M = 26
NumToStr = Chr(64 + M) & NumToStr
Num = (Num - M) / 26
Loop Until Num <= 0
End Function
···
网友评论