Results 1 to 4 of 4

Thread: Asc/Chr To Binary & visa versa ???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226

    Post

    I couldn't find any function/method to do the conversion!!

    Any help?

    Thanx

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    Post

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226

    Post

    Again, Philip thank you..

  4. #4
    Guest

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width