找回密码
 加入
搜索
查看: 2350|回复: 4

[AU3基础] 将数字转成纯英文26进位制或像Excel的行编号那样[已解决]

[复制链接]
发表于 2017-4-30 13:36:19 | 显示全部楼层 |阅读模式
本帖最后由 kk_lee69 于 2017-5-1 12:00 编辑

簡單的小程式,將數字轉成純英文26進位制,列如A、B、C、...、Y、Z、AA、AB、...、AZ、BA、...,
或像Excel的行編號那樣。
以下是網上找的資料 ,但是我除了AU3 其他的語言不懂

能幫我轉一下AU3的寫法嗎??

private static String engCounter(int value){
        String res = "";       
        while(value >= 26){
                res = ((char)((value % 26)+65)) + res;
                value /= 52;
        }
        res = ((char)((value % 26) + 65)) + res;
        return res;
}
发表于 2017-4-30 16:06:02 | 显示全部楼层
顺便做了测试代码


#include <Array.au3>

Global $aEnglish[100]
For $Num = 1 To 100
        $aEnglish[$Num - 1] = _NumberToEnglish($Num)
Next
_ArrayDisplay($aEnglish)

Func _NumberToEnglish($iNumber)
        Local $res = ""
        While $iNumber >= 26
                $res = Chr(Mod($iNumber, 26) + 65) & $res
                $iNumber /= 52
        WEnd
        $res = Chr(Mod($iNumber, 26) + 65) & $res
        Return $res
EndFunc
 楼主| 发表于 2017-4-30 23:10:21 | 显示全部楼层
回复 2# 帆船

謝啦 我測試看看  感謝!!
发表于 2017-5-1 09:18:47 | 显示全部楼层
回复 2# 帆船
学习了。但英文字母没有A?
发表于 2017-5-1 11:41:00 | 显示全部楼层
回复 4# chzj589
原始代码是以0为A的。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 20:44 , Processed in 0.079308 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表