PDA

Click to See Complete Forum and Search --> : Asc/Chr To Binary & visa versa ???


Lyla
Oct 20th, 1999, 12:26 PM
I couldn't find any function/method to do the conversion!!

Any help?

Thanx

PhilipG
Oct 20th, 1999, 12:44 PM
Converting to a Binary string is not directly available within VB as far as I know. If for some reason you actually need a value to display in binary then you can create a function that does this for you. Just declare an Array of Bits then convert the Asc value to its Decimal integer value. Then divide the Decimal value by two repeatedly. Each time you divide by two, the remainder is a bit. Typecast that bit to a string.

If your wanting to use the binary number just within your code manipulation, there isn't anything you can't already do with the Chr, Asc, Bit, Byte, and &H. All those types can handle just about anything.

Laters,
Phil

Lyla
Oct 20th, 1999, 12:53 PM
Again, Philip thank you.. ;)

Jan 18th, 2000, 06:38 AM
this will give you the binary string equivalent of every asc number (0-255) using the And function
(both have to be the same to give a 1
example:
10010101
00101001 and
=01000011 )

For k = 0 To 255
Temp = ""

For j = 7 To 0 Step -1

If k And (2 ^ j) Then
Temp = Temp & "1"
Else
Temp = Temp & "0"
End If

Next j

RL88(k) = Temp

Next k