Consulting

Results 1 to 10 of 10

Thread: Closed: Using Unicode

  1. #1

    Closed: Using Unicode

    Can one use unicode in a visual basic application to input Latin-Extended characters in a text box? Specific characters include A with a macron above it, which is unicode 0101. I can do ascii up to 255, but the latter characters that I need I don't know how to insert because they are unicode....please help

  2. #2
    BoardCoder
    Licensed Coder
    VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    I'm sure there must be an easier way but VB actually stores strings in memory as unicode so you can create a unocode string from a byte array using this function:

    [vba]
    Function UnicodeChar(code As Long) As String
    Dim b(0 To 1) As Byte
    b(0) = code \ 100
    b(1) = code - b(0) * 100
    UnicodeChar = b
    End Function
    [/vba]

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  3. #3
    VBAX Regular
    Joined
    May 2004
    Location
    London
    Posts
    8
    Location
    Use ChrW instead of Chr:[vba]ME.Textbox1.Text = ChrW(&H101)[/vba]

  4. #4
    BoardCoder
    Licensed Coder VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    Good spot Helen. I knew there must be a built in fucntion but I couldn't remember it off the top of my head! It was quicker to write out a new one!

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  5. #5
    VBAX Regular NateO's Avatar
    Joined
    Jun 2004
    Location
    Minneapolis, MN
    Posts
    90
    Location
    If you're going to stack a textbox with a string, you might as well spare yourself the overhead and use the string variety of the chrw function eh.

    E.g., ChrW$(257)
    Regards,
    Nate Oliver

  6. #6
    VBAX Regular NateO's Avatar
    Joined
    Jun 2004
    Location
    Minneapolis, MN
    Posts
    90
    Location

    Example

    Attached is an Example.
    Regards,
    Nate Oliver

  7. #7
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    John: Was this helpful?
    ~Anne Troy

  8. #8

    Using Unicode to insert a macron A (Latin Extended A) into a textbox....by way of Com

    NO, Dreamboat...it didn't help. I found out that VB doesn't recognize Unicode directly in the textboxes....

  9. #9
    BoardCoder
    Licensed Coder VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    Try a richtextbox.

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  10. #10
    You can delete the thread

Posting Permissions

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