当前位置: 代码迷 >> 综合 >> 二进制数字转为十六进制数
  详细解决方案

二进制数字转为十六进制数

热度:67   发布时间:2023-09-20 12:00:05.0
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim s As String
Dim ys As Integer
a = m: b = 16               (m为任意二进制数)
While a <> 0
ys = a Mod b
s = f(ys) & s
a = a \ b
Wend
Print s

End Sub

Private Function f(ys As Integer) As String
If ys <= 9 Then
f = ys
Else
Select Case ys
Case 10, 11, 12, 13, 14, 15
f = Chr(ys + 55)
End Select
End If



End Function