- Home
·
- Math/Dates
·
- Convert a long to a Binary string of 10101010101......
Convert a long to a Binary string of 10101010101......
Convert a long to a Binary string of "10101010101......"
API Declarations
Debug.? ConvLongToBinaryStr(15)
Returns: 1111
Notes:
Be creative and I am sure without much change you can take this code to handle any numeric base. Please feel free to improve the code and please let me know of any changes you would like to make to it. I love to learn how to write better code.
Rate Convert a long to a Binary string of 10101010101......
(2(2 Vote))
Dim lWorkNumber As Long
Dim nMod As Integer
Dim sRet As String
nMod = pi_ConvertMe Mod 2
lWorkNumber = (pi_ConvertMe - 0.5) / 2
If (pi_ConvertMe > 0) Then
If lWorkNumber > 0 Then
ConvLongToBinaryStr = ConvLongToBinaryStr(lWorkNumber) + CStr(nMod)
Else
ConvLongToBinaryStr = CStr(nMod)
End If
Else
ConvLongToBinaryStr = "0"
End If
End Function
Convert a long to a Binary string of 10101010101...... Comments
No comments yet — be the first to post one!
Post a Comment