十进制转换成十六进制算法

作者:vkvi 来源:千一网络(原创) 日期:2006-11-23
function OctToHex(n)
    if n < 16 then
        OctToHex = HexNumber(n)
    else
        OctToHex = CStr(OctToHex(n \ 16)) & HexNumber(n mod 16)
    end if
end function
function HexNumber(n)
    if n < 10 then
        HexNumber = CStr(n)
    elseif n = 10 then
        HexNumber = "A"
    elseif n = 11 then
        HexNumber = "B"
    elseif n = 12 then
        HexNumber = "C"
    elseif n = 13 then
        HexNumber = "D"
    elseif n = 14 then
        HexNumber = "E"
    elseif n = 15 then
        HexNumber = "F"
    end if
end function

相关阅读

相关文章