| 发表于:2008-01-09 08:21:344楼 得分:0 |
相同方法,附上二进制转八进制和十六进制代码 public function bintooct(byval sbin as string) as string const s1 = "0001011100", s2 = "01253764" dim i as integer, soct as string sbin = string(2 - (len(sbin) - 1) mod 3, "0") & sbin for i = 1 to len(sbin) step 3 soct = soct & mid(s2, instr(1, s1, mid(sbin, i, 3)), 1) next i bintooct = soct end function public function bintohex(byval sbin as string) as string const s1 = "0000101001101111000", s2 = "0125a4936db7fec8" dim i as integer, shex as string sbin = string(3 - (len(sbin) - 1) mod 4, "0") & sbin for i = 1 to len(sbin) step 4 shex = shex & mid(s2, instr(1, s1, mid(sbin, i, 4)), 1) next i bintohex = shex end function | | |
|