VB Forms in Hindi Unicode Fonts
Most of the applications I came accross are still using old hindi fonts based on ASCII character sets. And when I tried to build one form in Unicode got to know why! As soon as you paste a unicode string on a control or the property window or the code area the string changes to a series of question marks????????
So should I too start using the same old way? I tried searching the net and this is what I came up with.
Though Visual Basic uses UTF-8 for internally handling the unicode text, the development interface that is provides suffers from a shortcoming that spoils all efforts in developing a unicode font based application. While working on property window, or the code window or saving control's propertybag the Visual Basic takes to convert the strings to charset defined by ANSI loosing the unicode data.
OK, then the alternate solution would be to save the uncode text on a seperate file which would be read and the language text populated during runtime. The catch here is that the controls we intend to use also do the same thing i.e. converting the unicode data to ANSI. However, the corresponding controls available with "Microsoft Forms 2.0 Object Library" are capable of showing the unicode texts.
Create a new project and add a label, commandbutton, textbox, listbox, combobox, checkbox, option button and a toggle button from the Forms 2.0 library controls. The default names of all these would be Label1, CommandButton1, TextBox1, listBox1, ComboBox1, CheckBox1, OptionButton1, ToggleButton1 resp. Change fonts for all these controls to "Arial unicode MS" with font-size 10 or above. "Arial unicode MS" fonts has glyphs for a number of languages including the "Devnagari Script"
Now we would keep our text in an external unicode txt file unitext.txt placed in the same folder as our application. We could have used a resource file too but as our purpose here is just check the feasibility of using unicode fonts on VB forms we will just keep things as discussed. our text file contains the text as below.
लेबल
कमांड बटन
टेक्स्ट बॉक्स
लिस्ट बॉक्स
काँबो बॉक्स
चेक बॉक्स
ऑप्शन बटन
टॉगल बटन
Add a reference to "Microsoft ActiveX Data Objects 2.6 Library". We would use it's Stream object to read the text file.
Paste the code below to load event of the form.
Private Sub Form_Load()
Dim objStream As New ADODB.Stream
Dim strFullText As String
Dim varTextLines As Variant
objStream.Charset = "Unicode"
objStream.Open
objStream.LoadFromFile "unitext.txt"
strFullText = objStream.ReadText
varTextLines = Split(strFullText, vbCrLf)
Label1.Caption = varTextLines(0)
CommandButton1.Caption = varTextLines(1)
TextBox1.Text = varTextLines(2)
ListBox1.AddItem varTextLines(3)
ComboBox1.Value = varTextLines(4)
CheckBox1.Caption = varTextLines(5)
OptionButton1.Caption = varTextLines(6)
ToggleButton1.Caption = varTextLines(7)
End Sub
The code above reads the unitext.txt file and splitting it with each occurrance of vbCrLf gets the text for each control in form of an array which it later assigns it to the controls. The purpose of this post was to demonstrate using unicode font in VB. See what difference it can make to your aplication.
| The VB Form with English Text | The same form with Hindi Unicode text |
|---|---|
|
|



April 3rd, 2007 - 06:23
Very Informative. But when i stored the same text strings in a database, and when i try to display the same data, it is again come as a ????? .
Do you have any solution for that.
Regards
Amit
April 4th, 2007 - 11:28
Its a very Good Question from Amit?? Lot of people face these issue. if you could put up a sample to store and retrive the same text from database its very useful.
regards
April 5th, 2007 - 04:03
The problem arises mainly due to some functions converting the text to ANSI before storing or displaying data.
Suggessions accepted, and I will try to include a post on storing, retrieving and displaying unicode data, asap.
April 9th, 2007 - 05:42
Thank you very much i shall be very greatful!! Thanks for your kind response
April 11th, 2007 - 10:03
when you got the solution, kindly post the URL as comment here, or if you don’t mind kindly drop me a mail.
Regards
Amit
April 12th, 2007 - 11:35
Unicode data storage issue as posted in comments by Amit & Phil has been taken in recent post Storing Unicode Data in Databases
April 15th, 2007 - 15:29
Sir
i am Astt. Programer
Unicode Fount(mangal)to English at visual basic 6.0
May 9th, 2007 - 10:23
good solution
also i need to convert utf-8 data to ansi mode
how can i do this by replacing all the special charactors to entity values
pls. help
July 6th, 2007 - 12:30
Thank you very much.
U solved our big problem
July 30th, 2007 - 11:42
This is very useful, but if i want to mak customize software as according to my language.
how will vb support it.
September 7th, 2007 - 13:00
Has anyone found a way of displaying unicode text in the Form Caption?
November 1st, 2007 - 05:30
Dear sir
I follow all the steps mentioned. At runtime error no ‘3002′ with message “file couldnot be opened” is flashed.
pl. provide the solution.
Regards
Pankaj
November 1st, 2007 - 05:33
Hi
I followed the steps mentioned.But runtime error no 3002 with message file could not be opened is flashed.
Pl. provide solution.
Regards
Pankaj
November 1st, 2007 - 06:13
Problem might be one of the two
1) The text file is not present in the same folder as the executable.
2) The text file is already opened by some other application.
November 7th, 2007 - 12:30
Dear Sir
Thanks for your response.It is vary useful for me.
I create a text file using kruti 011 font.When i select font arial unicode ms the hindi text is changed.
Pl. advice me the font used in creating your text file “unicode.txt”
waiting for your responce.
regards
pankaj
November 8th, 2007 - 08:32
Dear Sir
Thanks for your response.It is vary useful for me.
I create a text file using kruti 011 font.When i select font arial unicode ms the hindi text is changed.
Pl. advice me the font used in creating your text file “unicode.txt”
waiting for your responce.
regards
pankaj
November 14th, 2007 - 04:07
@Pankaj
Kriti011 that you were using is a non-unicode hindi font… You feel how unicode and others differ please have a look at http://www.google.com/transliterate/indic/
Check the unicode text output that results from transliteration …
November 27th, 2007 - 20:15
This is Jamal ahmad Ansari this is very good information provided by you
i am software engineer earlier i have worked in vb6.0 now i have working in PHP
i am trying to create a application software that store hindi character in the database i had tried in vb6.0 but when we insert form data into database error is generated and application is crashed
can you provide me some help
Thanks
November 28th, 2007 - 13:55
See if the link below helps otherwise the details would be required to guess for what could be the reason.
jalaj.net/2007/04/12/storing-unicode-data-in-databases/
January 16th, 2008 - 16:05
me abhi seekh raha hu kuch baatya ki kese sekhe vb
February 2nd, 2008 - 07:39
How can we use unicode texts using resource file
February 2nd, 2008 - 07:40
Please help me in using unicode text(Chinese) using resource file.
Thanks in Advance.
March 19th, 2008 - 06:40
it not sufficient to me i want to change the menu and toolbar caption
April 23rd, 2008 - 07:20
hello,
if we r already having a form designed and now want to change it in hindi, then how can we convert existing labels, buttons in microsoft forms 2.0 object library’s labels and button?,
or we have to redesign it which will take more time n a tuff work.
plz help..
June 12th, 2008 - 08:09
i had a list of names in excel typed in english i want to convert its script language to hindi. please help how to get it done in vb or any other way u can suggest.
June 24th, 2008 - 09:21
i have some data in urdu in database (msaccess). i m using ADO in vb to access my data in vb form plz help me
Regards
June 25th, 2008 - 18:08
hello sir
thanks for your suggestion on different topic on unicode. I am student of mca and first time i am doing a project which have hindi font and i faced lots of problem. After searching i google i fallowed ur blogs .And there are very good related to this topic .Hope so u will send me replay
thanks
August 6th, 2008 - 06:04
hello,
Thank you for your information. That is very useful to me. I have another problem. I used components of Microsoft Forms 2.0 object library to display unicode data. I want to define new index for combo box because I want to display only City Name with combo box and City Code save as that index. What should I do?….. ordinary combo box(not unicode combo box) is ok for that with following code……
cbo.AddItem “CityName”
cbo.ItemData(cbo.NewIndex) = “CityCode”
if I want to get that new index,
cbo.ItemData(cbo.ListIndex)
if I want to use that logic in unicode combo box, ??????????????????????. Please suggest me……
thanks
August 8th, 2008 - 11:19
Hi we are trying the same example but we are not able to see the devanagari script. instead we are getting the ???? marks
August 22nd, 2008 - 16:01
Here is an equivalent:
Function get_unicode(file As String) As String
Dim file_id As Long
Dim cont() As Byte
file_id = FreeFile()
Open file For Binary As file_id
ReDim cont(LOF(file_id))
Get file_id, , cont()
get_unicode = cont()
Close file_id
End Function
August 24th, 2008 - 12:16
dear sir,
please give me info. that how we change windows default font to marathi(ex.dv-ttganesh).
September 19th, 2008 - 04:26
is there any alternative way to use unicode in visual baisc menus?
actually when i want to add unicode strings into menu captions it changes then into question marks.
please tell me if you know. I shall be very thank full to you.
October 15th, 2008 - 12:18
How to create string table in hindi? And load those string from string table at runtime? My application is in MFC…So is it possible to create string table in hindi in MFC?
October 17th, 2008 - 10:49
Hi, it’s very useful information…Thanks.
But how to write text in Hindi in the textfile(.txt)
I also want to create the same for Gujarati.
How to write in textfile in Hindi & Gujarati with “Arial Unicode MS” Font.
I am waiting for ur early rely!!!
October 27th, 2008 - 09:22
हैलो सर
श्रीमान जी मैं VB6 में हिन्दी फोन्ट मंगल (Script Font) का इस्तेमाल करना चाहता हूं। किन्तु वहां पर केवल ????????? ही आते है।
कृपया इस समस्या का हल भेजे।
धन्यवाद।
रिम्पु सिंगला
October 27th, 2008 - 09:33
कृपया उपरोक्त प्रोजेक्ट का कोड भेजे।
क्योंकि Arial Unicode MS में हमें Dev… नहीं मिला।
और केवल ?????????? ही आ रहे है।
December 29th, 2008 - 09:00
Thank you very much for information.
December 29th, 2008 - 09:25
Hi,
As sugested i have used unicode text box with gujrati shruti font. Everything is working fine except it sows big spaces between the wards. How do i resolve the problem?
Thanks in advance.
March 29th, 2009 - 09:45
you hv not notes in hivdi
April 28th, 2009 - 13:16
Sir the information above is very useful for me, many thanks for the above post. I have a query regarding using “Arial Unicode MS” font. I have downloaded it via internet. Its size is 22.2 MB approx., Sir when I use this font to set TextBox1’s Font property to “Arial Unicode MS”, I can’t find any option to set “Devnagari” glyph in font dialog box. Please guide me to solve this problem. The glyph available in list as under: -
Western
Japanese
Hangul
Hangul(Johnab)
Chinese_GB2312
Chinese_BIG5
Herbrew
Arabic
Greek
Turkish
Baltic
Central European
Cyrillic
Thai
Vietnamese
thankx in addvance…
July 7th, 2009 - 17:05
How do i put unicode fonts i.e Gujarati fonts on MSFlexGrid????
November 7th, 2009 - 04:27
धन्यवाद, मुझे यूनीकोड हिन्दी मे फ़ोर्म बनाने मे मदद मिली। पर मेनू आइट्म और फ़ोर्म का नाम हिन्दी मे केसे लिखे?
December 4th, 2009 - 03:31
the information is very useful for me as i am trying to build a text editor in hindi language using vb6. the problem is i am unable to change the language of menu items . i am not getting the way to do that. please provide me some suggestion if possible
December 17th, 2009 - 18:19
hie..!
tanQ verymuch for dis information..!
can we get “Arial Unicode MS” for free..!!
ver shall i get it..??
plz help me..!
regards
sAn.!