Unicode problem

Posted on 2004-11-05
Medium Priority
Last Modified: 2010-05-02
I have to develop an application using Arabic Interface. For this I am using Microsoft Forms 2.0 object Library and also changed the settings in Control Panel Regional Settings. I am using unicode for the first time. I am not sure about the approach or the way to do the same. Can anyone tell me the correct way to store in Unicode so that it is language independent.
Question by:ubbott
  • 3
LVL 53

Expert Comment

ID: 12503428
VB6 cannot display unicode characters.
You need to use 3rd party controls to do so.
MS Office has FM20.dll that is able to show unicode, but ppl need an MS Office license to use it.

Sources for third party Unicode controls:
1. UniSuite at http://www.cyberactivex.com
2. UniToolBox at http://www.unitoolbox.com/
3. Forms 2.0 Object Library.
   FM20.Dll - Microsoft® Office users already have Forms 2.0 Object Library installed. If not you can download and install it free as part of ActiveXControlPad at http://download.microsoft.com/download/activexcontrolpad/Install/
   FM20ENU.Dll - Automatically installed with English versions of Office. Users who have installed Office with another language should check Windows\System32 folder for presence of this file. If it is not present you can download and install it free as part of ActiveXControlPad.
   Note: You must have FM20ENU.Dll present to make Forms 2.0 Object Library controls available in Vb6. In the IDE you will receive an error while attempting to place the control on a Form. Typical messge is System Error &H8007007E(-2147024770).
LVL 16

Accepted Solution

jimbobmcgee earned 500 total points
ID: 12503633
VB6 controls cannot display Unicode characters, no, but VB6 uses Unicode for all its strings -- that is why there is LenB, ChrW, et al counterparts to many of the functions.

The Microsoft Forms 2.0 object Library and FM20.DLL are the same thing.  

When you say 'store' in Unicode, do you mean to a text file?  If so, do you know how to use the File System Object?  You can use it to store in UTF16/Unicode.  Place a reference to the Microsoft Scripting Runtime in your code and try the following small example of this in action:

      Dim myFSO as New Scripting.FileSystemObject
      Dim myTextStream as Scripting.TextStream

      Set myTextStream = myFSO.OpenTextFile("x:\mypath\myunicodefile.txt", ForWriting, True, TristateTrue)

            myTextStream.Write "My Ứתїč○đﻉ text"

      Set myTextStream = Nothing
      Set My FSO = Nothing

The CreateTextFile() method of the FileSystemObject has the following properties:

      CreateTextFile(Filename As String, IOMode As Enum, CreateIfNotExist As Boolean, TristateFormat As Enum)

Use ForWriting, ForReading, ForAppending as the IOMode and TriStateTrue for Unicode, TriStateFalse for ASCII, TriStateUseDefault for System Default.

For more info on the FSO, go to http://msdn.microsoft.com/library/en-us/script56/html/FSOoriFileSystemObject.asp

You may also want to look up the APIs WideCharToMultibyte() and MultibyteToWideChar(), from http://www.allapi.net, but it depends how far you want to go...


LVL 16

Expert Comment

ID: 12503683
Ooops, it looks like these pages don't show unicode text, either!!  Typical.  This line:

        myTextStream.Write "My Ứתїč○đﻉ text"

was a fancy unicode line of text.  Recreate it by changing that line to:

        myTextStream.Write "My " & ChrW(7912) & ChrW(1514) & ChrW(1111) & ChrW(269) & _
                                       ChrW(9675) & ChrW(273) & ChrW(65225) & " text"

to see why I'm so disappointed!! ;-)


Author Comment

ID: 12622312
Hi Jimbobmcgee..
Thanks for the comments. I had worked with FSO. In the example you had stored some data in text file using Cherw(). It works but if we have to use some database say SQL then can same is applied to that and moreover the way to read a unicode stored database.

LVL 16

Expert Comment

ID: 12653422
I would have thought that, if the database fields will store a Unicode string (an nVarchar, for example), it would be OK.  As far as I know, the ADODB.Recordset object is Unicode-compliant.  VB6 String variables certainly are.  

As such, I imagine you could pull data from Unicode fields into a recordset and output data using the FSO method...



Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question