Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unicode in VB IDE (VB 6 SP5)

    I'm running VB6 SP5 on XP SP2. I'd like to have a form that displays a TreeView control with nodes' text appearing in several languages, including Chinese Traditional and Japanese. As a test of my code, I wanted to populate the nodes from code by adding new nodes. However, when I hard-code strings in Chinese, the characters are converted to numbers.

    I realize that this is because the Unicode characters aren't being handled properly, but don't understand why. I thought VB was Unicode-compliant...shouldn't the IDE be as well? Can someone shed some light on what I might be doing wrong?

    Also, I will need to do the same thing in VBA (Office 2003).

    Thanks,
    Ziggy

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Unicode in VB IDE (VB 6 SP5)

    The Visual Basic Editor still uses 8-bit characters, so it cannot handle Unicode characters in literal strings. You need to use hex codes. You can manipulate Unicode characters in string variables, however.
    The same holds for Office VBA, for the Visual Basic Editor in Office 2000 and up is based on the VB6 editor.

  4. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unicode in VB IDE (VB 6 SP5)

    Thanks Hans. However, I thought I could write a program that could at least display Unicode text in a text box or TreeView control, but this also seems to fail (see attached zipped project -- it looks for Chinese.txt in c.

    Please don't tell me I need to use an OLE Container control with an instance of Word jut to display Unicode data!

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Unicode in VB IDE (VB 6 SP5)

    From browsing the newsgroups I get the impression that the treeview control is not unicode-aware either. <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15> You should be able to display Chinese characters by selecting the correct language in the Regional Settings control panel, but you wouldn't be able to mix character sets (as you would be able to do in unicode)
    Some newsgroup posts suggest using Windows API functions to control the TreeView directly, but that is far beyond my expertise.
    .Net should have better support for unicode.

  6. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unicode in VB IDE (VB 6 SP5)

    OK, figured it out finally. VB native controls don't support Unicode. The ironic thing is that vba User Forms 2.0 (which I always considered inferior to native vb forms/controls) DO support Unicode. However, the TreeView control in either environment does not support Unicode. So, in VB, I can add the User Forms 2.0 components to my project and use those controls in place of the VB native controls.

    The other problem is that I had neglected to change the font from the default Tahoma to a Unicode-enabled font, such as Arial Unicode MS! D'OH!!!

    One solution to the TreeView problem is to use a Unicode-enabled control that can provide a tree interface. There are many 3rd-party products available, but I will likely use VSFlexGrid, which claims to be able to bind its Outline view (pseudo-treeview mode) to a data source (xml, even COM objects). It has many flavors of the grid available (Light, heavy, Unicode, non-Unicode, etc.), so there truly is flexibility there.

    I'd be interested to hear of anyone else's experiences with this issue and how they resolved it.

Posting Permissions

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