vb中把十进制转换为二进制的程序怎么写 急求 T_T
2个回答
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询