加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB 二进制,八进制,十进制,十六进制转换-.NET教程,VB.Net语言

发布时间:2020-12-16 23:18:30 所属栏目:大数据 来源:网络整理
导读:public function d_to_b(byval dec as long) as string do d_to_b = dec mod 2 d_to_b dec = dec / 2 loop while dec end function public function b_to_d(byval bin as string) as integer dim i as long for i = 1 to len(bin) b_to_d = b_to_d * 2 + val

public function d_to_b(byval dec as long) as string do d_to_b = dec mod 2 & d_to_b dec = dec / 2 loop while dec end function public function b_to_d(byval bin as string) as integer dim i as long for i = 1 to len(bin) b_to_d = b_to_d * 2 + val(mid(bin,i,1)) next i end function public function h_to_b(byval hex as string) as string dim i as long dim b as string hex = ucase(hex) for i = 1 to len(hex) select case mid(hex,1) case "0": b = b & "0000" case "1": b = b & "0001" case "2": b = b & "0010" case "3": b = b & "0011" case "4": b = b & "0100" case "5": b = b & "0101" case "6": b = b & "0110" case "7": b = b & "0111" case "8": b = b & "1000" case "9": b = b & "1001" case "a": b = b & "1010" case "b": b = b & "1011" case "c": b = b & "1100" case "d": b = b & "1101" case "e": b = b & "1110" case "f": b = b & "1111" end select next i while left(b,1) = "0" b = right(b,len(b) - 1) wend h_to_b = b end function public function b_to_h(byval bin as string) as string dim i as long dim h as string if len(bin) mod 4 <> 0 then bin = string(4 - len(bin) mod 4,"0") & bin end if for i = 1 to len(bin) step 4select case mid(bin,4) case "0000": h = h & "0" case "0001": h = h & "1" case "0010": h = h & "2" case "0011": h = h & "3" case "0100": h = h & "4" case "0101": h = h & "5" case "0110": h = h & "6" case "0111": h = h & "7" case "1000": h = h & "8" case "1001": h = h & "9" case "1010": h = h & "a" case "1011": h = h & "b" case "1100": h = h & "c" case "1101": h = h & "d" case "1110": h = h & "e" case "1111": h = h & "f" end select next i b_to_h = h end function

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读