| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 921 人关注过本帖
标题:请问:VB6二进制转化十六进制该如何做?
只看楼主 加入收藏
小巨
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2008-5-10
收藏
 问题点数:0 回复次数:5 
请问:VB6二进制转化十六进制该如何做?
二进制转化十六进制该如何做?  还有十进制转化二进制?  十六进制转化成二进制
能否一个函数实现?   
例如:十进制转换成十六进制用hex()一样!
麻烦大虾们帮帮忙!
搜索更多相关主题的帖子: 二进制 十六进制 十进制 hex 
2008-05-14 19:13
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
自己找。
2008-05-14 21:35
exition
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-4-18
收藏
得分:0 
Public Function B_To_H(ByVal Bin As String) As String

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 4
Select Case Mid(Bin, i, 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
2008-05-14 23:05
exition
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-4-18
收藏
得分:0 
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
2008-05-14 23:05
exition
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-4-18
收藏
得分:0 
Public Function H_To_B(ByVal Hex As String) As String

Dim b As String

Hex = UCase(Hex)
For i = 1 To Len(Hex)
Select Case Mid(Hex, i, 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"
Case Else
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
2008-05-14 23:06
小巨
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2008-5-10
收藏
得分:0 
谢谢拉
2008-05-16 13:20
快速回复:请问:VB6二进制转化十六进制该如何做?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035554 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved