经尉迟方兄提点,终于明白为什么不是一个简单的26进制程序了

题目如下:

用过excel的都知道excel的列编号是这样的:
a b c .... z aa ab ac .... az ba bb bc .... yz za zb zc .... zz aaa aab aac ....
分别代表以下编号:
1 2 3 .... 26 27 28 29 .... 52 53 54 55 .... 676 677 678 679 .... 702 703 704 705 ....

请写个函数,完成从一个正整数到这种字符串之间的转换。
Public Function intcstr(ByVal ints As IntegerAs String 
Dim strs As String 
strs 
= Nothing 
Do While (ints Mod 26<> 0 Or ints / 26 <> 0 
If ints Mod 26 = 0 Then 
ints 
= ints / 26 - 1 
strs 
= Chr(96 + 26& strs 
Else 
strs 
= Chr(96 + (ints Mod 26)) & strs 
ints 
= Int(ints / 26
End If 
Loop 
Return strs 
End Function
 
原文地址:https://www.cnblogs.com/aowind/p/136898.html