Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unicode Display In Visual Basic With VB Controls...

Posted on 2003-02-27
11
Medium Priority
?
227 Views
Last Modified: 2013-11-25
Hi Hi!

Something that I really need some feedback from anyone who had done this before. I'm trying to display some unicode character ( eg: chinese, japanese character ) into the message box. But then what I got is just " ??? " character.

I know that by starting the program like Chinese Star, I will be able to view it correctly but I'm trying to develop a program that we don't have to start a third party software to run the program correctly.

I managed to find out that Microsoft Form 2 Objects support unicode character but I'm still searching for solutions on the menu and message box on how to display the unicode character out without having to run a third party software.

Anyone with any ideas on how to do this? Thanks for the help in advance !

0
Comment
Question by:gilabean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 

Accepted Solution

by:
catalin_tata earned 300 total points
ID: 8040150
You can try the following:
  1.Instead of use the VB MsgBox function for displaying the message try to use the unicode version of the WIndows API MessageBox...this is the declaration:

Public Declare Function MessageBox Lib "user32" Alias "MessageBoxW" (ByVal hwnd As Long,lpText As Any, ByVal lpCaption As String, ByVal wType As Long) As Long


0
 

Expert Comment

by:catalin_tata
ID: 8040158
You can try the following:
  1.Instead of use the VB MsgBox function for displaying the message try to use the unicode version of the WIndows API MessageBox...this is the declaration:

Public Declare Function MessageBox Lib "user32" Alias "MessageBoxW" (ByVal hwnd As Long,lpText As Any, ByVal lpCaption As String, ByVal wType As Long) As Long
   
   2.Do not pass the VB string directly,convert the string in a bytes array.A unicode character have 2 bytes.
   
   If you need more information,just let me know
   Regards,Catalin

0
 

Author Comment

by:gilabean
ID: 8040296
I don't really know how to use the API coz..I haven't use it before.

It would be great if you can give me an example on the usage of the messagebox.

thanks in advance.
:)

Cheers,
gilabean
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:gilabean
ID: 8040355
I don't really know how to use the API coz..I haven't use it before.

It would be great if you can give me an example on the usage of the messagebox.

thanks in advance.
:)

Cheers,
gilabean
0
 

Expert Comment

by:catalin_tata
ID: 8040537
First thing that you need to have in mind when starting with api is the API text viewer utility that you can find in the Microsoft Visual Studio tools. There you can find declaration of functions,constants and types that can be use in VB when calling a API.
I show you an example with the usage of the MessageBox Api

In a vb module place the declaration:

Public Declare Function MessageBox Lib "user32" Alias "MessageBoxW" (ByVal hwnd As Long,lpText As Any, ByVal lpCaption As String, ByVal wType As Long) As Long

Public Const MB_OK = &H0&


then in youur program when you call the MsgBox use this:

strText="Message Box title in chinese" 'this is the text that will be put on the message box and can be any unicode character
msgTextB() as byte
Redim msgTextB(Len(strText)*2)
for i=1 to len(strText)
 msgTextB(i*2-1)=Ascw(Mid(strText,i,1))/256-1
 msgTextB(i*2)=Ascw(Mid(strText,i,1))mod 256
next i
MessageBox(frmMain.hwnd,msgtextB(0),"Box caption",MB_OK)

Hope this help you
Regards,Catalin

0
 

Author Comment

by:gilabean
ID: 8040624
I don't really know how to use the API coz..I haven't use it before.

It would be great if you can give me an example on the usage of the messagebox.

thanks in advance.
:)

Cheers,
gilabean
0
 

Author Comment

by:gilabean
ID: 8040725
I managed to display unicode character out but then the displayed text is not displayed correctly.

Let's say that I used chinese simplified character but when it output out in the messagebox, the displayed caption is not what I type.....

*headache* LoL

cheers,
gilabean
0
 
LVL 5

Expert Comment

by:Rhaedes
ID: 8040855
The above should work fine, but another approach might be just to simulate a msgbox using a small form with a (From 2.0 Object) label on it, and a command button to 'accept'.

For instance, create a small form called, say ChMsgbox. Put a Label on it (label1) and a commandbutton (Command1).
The form should only contain the following code, to enable the user to accept:

Private Sub Command1_Click()
Unload Me
End Sub

To call the fake msgbox, include this sub in the main form:

Private Sub UnicMsgBox(myMessage)
With ChMsgbox
.Show
.Label1.Font = "Arial Unicode MS"
.Label1.Caption = myMessage
End With
End Sub

Now, to make the message appear, simply use something like:

UnicMsgBox ChrW(20000) + ChrW(20001) + ChrW(20002)

Hope this helps,
but again, the API call is more satisfying.
Kindest regards,
Rhaedes
0
 

Expert Comment

by:CleanupPing
ID: 8901000
gilabean:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9001559
Moderator, my recommended disposition is:

    Accept catalin_tata's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

704 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