Dim s As String
Dim n, f As Double
Private Sub Command1_Click()
n = Val(Text1.Text)
While n > 15
f = n \ 16
n = (n - f * 16)
Nfa (f)
Wend
Nfa (n)
Text2.Text = s
End Sub
Public Function Nfa(m As Double)
Select Case Int(m)
Case 10:
s = s + "a"
Case 11:
s = s + "b"
Case 12:
s = s + "c"
Case 13:
s = s + "d"
Case 14:
s = s + "e"
Case 15:
s = s + "f"
Case Else
s = s + Trim(Str(m))
End Select
End Function
Private Sub Command2_Click()
Dim a As Double, X As String
a = 40567893482#
X = Hex(Int(a / 16 ^ 6)) & Right("000000" & Hex(a - Int(a / 16 ^ 6) * 16 ^ 6), 6)
MsgBox X
End Sub
Private Sub Command1_Click()
Dim a As Double, x As String
a = 40567893482#
Do While a > 10000
x = Hex(Val(Right(a, 4)) Mod 16) & x
a = Int(a / 16)
Loop
x = Hex(a) & x
MsgBox x
End Sub
转发
Function Bin2Hex(InputData As String) As String
Dim I As Integer
Dim LenBin As Integer
Dim JOne As String
Dim NumBlocks As Integer
Dim FullBin As String
Dim HexOut As String
Dim TempBinBlock As String
Dim TempHex As String
LenBin = Len(InputData)
For I = 1 To LenBin
JOne = Mid(InputData, I, 1)
If JOne <> "0" And JOne <> "1" Then
MsgBox "NOT A BINARY NUMBER", vbCritical
Exit Function
End If
Next I
FullBin = InputData
If LenBin < 4 Then
If LenBin = 3 Then
FullBin = "0" + FullBin
ElseIf LenBin = 2 Then
FullBin = "00" + FullBin
ElseIf LenBin = 1 Then
FullBin = "000" + FullBin
ElseIf LenBin = 0 Then
MsgBox "Nothing Given..", vbCritical
Exit Function
End If
NumBlocks = 1
GoTo DoBlocks
End If
If LenBin = 4 Then
NumBlocks = 1
GoTo DoBlocks
End If
If LenBin > 4 Then
Dim TempHold As Currency
Dim TempDiv As Currency
Dim AfterDot As Integer
Dim Pos As Integer