is there a fuction to convert a number to binary if not how do i do it...
thanks
brooke
Printable View
is there a fuction to convert a number to binary if not how do i do it...
thanks
brooke
Try this:
Dim xint as integer
dim StrString as string
xint = any integer
do until xint <= 0
if raminder(xint,2) > 0 then
StrString = '1' & StrString
xint = (xint-1)/2
else
StrString = '0' & StrString
xint = xint/2
end if
loop
StrSting = binary number
It doesn't work...
Take a look at this article, it has exactly
what you are looking for.
http://www.vb-world.net/misc/addins/
Try this
Public Function Bin_conv(Byval value as long) as string
Dim multi As Long
Dim binary As Variant
multi = 0
binary = 0
If value > 2048 Then
msgbox = "**Overflow**"
Exit Function
End If
Do While (value > 0)
remainder = value Mod 2
value = Fix(value / 2)
If remainder = 1 Then binary = binary + 10 ^ multi
multi = multi + 1
Loop
Bin_conv = binary
End Function