vbs-二进制转16进制

'二进制转16进制
'binary二进制字符串
Function binaryToHex(binary)
	binary_len = len(binary)
	quyu = binary_len mod 4
	If quyu <> 0 then 
		ss = 5/0
	End If
	hex_len = binary_len/4
	For i = 1 To hex_len
		start_index = (i-1)*4+1
		binary_sub = mid(binary,start_index,4)
		hex_str = ""
		If binary_sub = "0000" then hex_str = "0"
		If binary_sub = "0001" then hex_str = "1"
		If binary_sub = "0010" then hex_str = "2"
		If binary_sub = "0011" then hex_str = "3"
		If binary_sub = "0100" then hex_str = "4"
		If binary_sub = "0101" then hex_str = "5"
		If binary_sub = "0110" then hex_str = "6"
		If binary_sub = "0111" then hex_str = "7"
		If binary_sub = "1000" then hex_str = "8"
		If binary_sub = "1001" then hex_str = "9"
		If binary_sub = "1010" then hex_str = "a"
		If binary_sub = "1011" then hex_str = "b"
		If binary_sub = "1100" then hex_str = "c"
		If binary_sub = "1101" then hex_str = "d"
		If binary_sub = "1110" then hex_str = "e"
		If binary_sub = "1111" then hex_str = "f"
		binaryToHex = binaryToHex & hex_str
	Next
End Function

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值