| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: How can I convert a Hex number to a binary number? |
> I am using the following function for decimal numbers but I have a
neeed to
> convert hex to binary.
>
> Public Function Binary(Number As Long) As String
> If Abs(Number) > 1 Then
> Binary = Binary(Number \ 2) & CStr(Abs(Number Mod 2))
> Else
> Binary = CStr(Number)
> End If
> End Function
' Limit on the size the HexString value is 2147483648 hex-digits
Function Hex2Bin(ByVal HexString As String, _
Optional WithBlanks As Boolean) As Variant
Dim X As Integer
Const BinValues = "0000000100100011" & _
"0100010101100111" & _
"1000100110101011" & _
"1100110111101111"
If UCase$(Left$(HexString, 2)) = "&h" Then
HexString = Mid$(HexString, 3)
End If
For X = 1 To Len(HexString)
Hex2Bin = Hex2Bin & Mid$(BinValues, _
4 * Val("&h" & Mid$(HexString, X, 1)) + 1, 4)
If WithBlanks Then Hex2Bin = Hex2Bin & " "
Next
End Function
Rick - MVP
--- UseNet To RIME Gateway {at} 2/10/05 2:47:00 PM ---
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)SEEN-BY: 633/267 270 5030/786 @PATH: 278/230 10/345 106/1 2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.