Results 1 to 4 of 4

Thread: Coding for character-by-character from a textbox?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210

    Coding for character-by-character from a textbox?

    I want to make a text to binary converter, but i can't think of a way to take "abc" into "0110 0001 0110 0010 0110 0011".
    unless I make like 50 textboxes, I don't think it's possible to convert like that with the information I have, which is really... really... tiny... tiny...
    Ayway.
    There has to be a way, right?
    Would someone help me on this, please?
    Thanks.

  2. #2
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    You could do something like this:
    VB Code:
    1. Dim c As Char
    2. Dim myStr As String = "ABC"
    3. Dim o As String
    4.  
    5. For Each c In myStr  'Tells the computer to do something for each character in the string
    6.      o &= "add something to the string o, can be anything ex. 0010"
    7. Next

    Jeremy

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    Is there another way?

    It seems like the code above won't properly convert a string with multiple same characters... I'm trying it now tho.

    I just tried it, and if there were more than one For...Each statement, the result turned out.. weird.. iono..
    Last edited by nahya^^; Dec 13th, 2002 at 04:57 PM.

  4. #4
    Junior Member RvA's Avatar
    Join Date
    Oct 2002
    Location
    USA
    Posts
    19
    Well I can get you a group of Hex values......

    VB Code:
    1. Dim I As Integer
    2.     Dim sData As String = "AAaaBBbbCCcc"
    3.     Dim sRtn, sTmp As String
    4.  
    5.     For I = 1 To Len(sData)
    6.       sTmp = Hex(Asc(Mid(sData, I, 1))) & " "
    7.       sRtn = sRtn & sTmp
    8.     Next
    9.  
    10.     MsgBox(sRtn)
    Best,

    Roger

    VB6.0 SR5 & VB.Net Pro
    -----------------------------------------------
    Do or do not, there is no try!

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