Results 1 to 4 of 4

Thread: [RESOLVED] Chr() and Asc() help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    126

    [RESOLVED] Chr() and Asc() help

    Not sure if any of this will make sense without the whole code but...
    VB Code:
    1. For a = 1 To Len(Data)
    2. PrintText = PrintText & " " & ChrB(Asc(Right(Left(Data, 1), Len(Data) - a + 1)) + Keycode(a))
    3. 'MsgBox a
    4. 'MsgBox ChrB(Asc(Right(Left(Data, a), Len(Data) - a + 1)) + Keycode(a))
    5. Next
    6. 'MsgBox PrintText
    Basically, it gets ever letter, switches to its ascii value, adds the variable Keycode to it, then changes back into Chr()

    Anywany, print text is supposed to string all the letters together, IE.

    If the first letter converts to "æ"
    then second letter converts to "£"
    and the third letter converts to "₧"
    printText should give the value "æ £ ₧"

    But for some reason it ends up with "??Ü" or something similar

    I have the msgbox's to check that the letters are being evaluated properly, and they are, but the PrintText is getting messed up somewhere




    Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
    Last edited by Robert123; Aug 26th, 2005 at 09:25 AM.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Chr() and Asc() help

    To me it seems the entire attempt at getting the letter is wrong. You can't just use this?
    VB Code:
    1. Dim a As Long
    2. For a = 1 To Len(Data)
    3.     PrintText = PrintText & " " & Asc(Mid$(Data, i, 1)) & Keycode(a))
    4. Next a
    ..does that not do the same thing?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    126

    Re: Chr() and Asc() help

    Awesome it works, thanks alot =D Didn't know about Mid()

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Chr() and Asc() help

    np

    Remember to mark your thread as Resolved.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

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