Private Sub Command1_Click()
Dim n As Long
n = Val(Text1.Text)
Text2.Text = ""
Do While n > 0
Text2.Text = (n Mod 2) & Text2.Text
n = n \ 2
Loop
End Sub
Option Explicit
Dim sBin As String
Dim sHex As String
Private Sub Command1_Click()
sHex = Hex(Val(Text1))
Text2 = sHex
HexToBin (sHex)
Text3 = sBin
sBin = ""
End Sub
Private Sub Form_Load()
Text1 = ""
End Sub
Public Function HexToBin(ByVal sHex As String) As String '处理16进制转换2进制代码
Const s1 = "0000101001101111000", s2 = "0125A4936DB7FEC8"
Dim i As Integer
sHex = UCase(sHex)
For i = 1 To Len(sHex)
sBin = sBin & Mid(s1, InStr(1, s2, Mid(sHex, i, 1)), 4)
Next i
End Function