Office中国论坛/Access中国论坛

标题: 进制转换! [打印本页]

作者: 真主    时间: 2005-1-17 18:36
标题: 进制转换!
我在查询中要把一个字段“117483712”先转成“十六进制”,如:[分成四部分,位数不足,在左边加0:07.00.A8.C0],将每部分转成十进制:7.0.168.192,再翻转成IP:192.168.0.7

[此贴子已经被作者于2005-1-17 11:23:26编辑过]


作者: Trynew    时间: 2005-1-18 00:32
Public Function IntToIp(Num As Long) As String

    Dim LenNum As Integer

    IntToIp = Right("00000000" & Hex(Num), 8)

    IntToIp = Val("&H" & Mid(IntToIp, 7, 2)) & "." & Val("&H" & Mid(IntToIp, 5, 2)) & "." & Val("&H" & Mid(IntToIp, 3, 2)) & "." & Val("&H" & Mid(IntToIp, 1, 2))

End Function






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3