您的位置:首页 > 编程语言 > VB

二进制转十六进制vb6程序

2015-12-04 10:05 597 查看
【原】二进制转十六进制vb6程序

Private Sub Command1_Click()

Dim strN As String, iHex As String, strBin(), strHex()

Dim intXh As Integer, i As Integer, j As Integer, strTmp As String

strBin = Array("0000", "0001", "0010", "0011", _

"0100", "0101", "0110", "0111", _

"1000", "1001", "1010", "1011", _

"1100", "1101", "1110", "1111")

strHex = Array("0", "1", "2", "3", "4", "5", "6", "7", _

"8", "9", "A", "B", "C", "D", "E", "F")

strN = InputBox("", "", "111000111")

If Len(strN) Mod 4 <> 0 Then strN = String(4 - Len(strN) Mod 4, "0") & strN

intXh = Len(strN) \ 4

For i = 1 To intXh

strTmp = Right(strN, 4)

For j = 0 To 15

If strTmp = strBin(j) Then

iHex = strHex(j) & iHex

Exit For

End If

Next

strN = Left(strN, Len(strN) - 4)

Next

MsgBox "0x" & iHex

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: