Hello all
Does anyone know how to get a decimal number into binary format in vb6? is there a built in function that will do this in VB6 like hex$??
Thanks all!
Printable View
Hello all
Does anyone know how to get a decimal number into binary format in vb6? is there a built in function that will do this in VB6 like hex$??
Thanks all!
This is brand new code for all base conversations
Code:' - - - - - - - K E D A M A N S C O D E- - - - - - -30.5.00
' Base mod decimal converters
'IE bin 2 dec
' Base2dec("1234",2)
' oct 2 bin
' dec2base(Base2dec("1234",8),2)
'trin 2 hex
' dec2base(Base2dec("1234",3),16)
Function Base2Dec(val$, base%): Dim n%
For n = 1 To Len(val)
Base2Dec = CDec(Base2Dec + Mid(val, n, 1) * base ^ (Len(val) - n))
Next n
End Function
Function Dec2Base$(val, base%): Dim n%
For n = 0 To 100
s = Int(val / base ^ n):
If s = 0 Then Exit For
s = s - Int(s / base) * base 's mod base
Dec2Base = s & Dec2Base
Next n
End Function
Hey Kedaman
Thanks a LOT!
the code worked really well!
=)