Solved

vb.NET characters

Posted on 2004-09-20
8
1,699 Views
Last Modified: 2013-12-02
Hi all. In my program I use English letters, Greek letters and math operation characters. In order to display a math operation, I use the "Symbol" font and a font like Arial for English. It is very slow the first time (when loading)...
A problem is that a value like chr(100) may represent different characters in two different fonts...by the way switching between fonts is agonizing.
so I often use things like:   str.Replace(chr(123),"something")
Any idea ?
Do you know how I can use the Unicode?
Do you know a font that would have all the English+Greek+Math characters?
0
Comment
Question by:Dan-Key
  • 3
  • 3
  • 2
8 Comments
 
LVL 12

Expert Comment

by:fulscher
ID: 12109921
Dan-Key,

you are using Unicode by default. The only way to avoid the replacement stuff is by using a font which has all the characters you need - or by creating a class which encapsulates this stuff so that you could use shortcuts like GreekFont.Alpha to get the Alpha character. However, this would still be lots of code (one or more lines for each character you eventually may use).

I just checked quickly in my font collection (2000 fonts) but haven't found a font which contains normal characters and greek and symbol characters. You might want to check out http://cgm.cs.mcgill.ca/~luc/math.html which contains lots of math fonts.

HTH, Jan
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 100 total points
ID: 12110976
Hi Dan-Key,

Almost all fonts (including Arial) contain the greek and math characters in their extended character set
try this

        Dim unicodeString As String = _
            "This Unicode string contains two characters " & _
            "with codes outside the traditional ASCII code range, " & _
            "Pi (" & ChrW(928) & ") and Sigma (" & ChrW(931) & ")."

        TextBox1.Text = unicodestring
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12111044
Just look in the character map and convert the code from hex to integer
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Dan-Key
ID: 12119436
Thanks for the comments.
Ronald, I had used chr(integer code)  and now chrw() is pretty much the same.
Using character map is no use since I need to know the integer value not Hex
I have problem using the Unicode numbers.
Where did you get the number 931 for sigma??? Everywhere I look I see 2211 for that and when I use chrw(2211) it displays the invalid square box.

Example: the Unicode of product sign is 220F
the following does not work:
        MsgBox(Convert.ToChar(220F))
The following shows an unexpected sign:
        MsgBox(ChrW(220.0F))

0
 
LVL 12

Expert Comment

by:fulscher
ID: 12120082
Dan-Key,

try the following:

   Public Enum GreekUpper
        Alpha = &H391
        Beta
        Gamma
        Delta
        Epsilon
        Zeta
        Eta
        Theta
        Iota
        Kappa
        Lambda
        Mu
        Nu
        Xi
        Omicron
        Pi
        Rho
        Sigma = &H3A3
        Tau
        Ypsilon
        Phi
        Chi
        Psi
        Omega
    End Enum

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox(ChrW(GreekUpper.Phi))
    End Sub


Jan
0
 
LVL 25

Assisted Solution

by:RonaldBiemans
RonaldBiemans earned 100 total points
ID: 12120275
- Using character map is no use since I need to know the integer value not Hex

but you do have a calculator on your computer, which in scientific mode can convert hex to decimal.

So when you look in the character map and choose uppercase sigma it will say 3a3
open your calculator choose the radiobutton Hex, type in 3a3 then choose the radiobutton Dec and voila it will say 931

Then you can make the enum like fulcher described for lowercase greek aswell
0
 
LVL 12

Expert Comment

by:fulscher
ID: 12120406
Just to clarify: By preceeding a hex number with &H..., you can use it directly in VB. If character map says "03A3", you would use &H03A3 or &H3A3 in VB.

Jan
0
 

Author Comment

by:Dan-Key
ID: 12129529
Thanks to both of you.
fulscher, thank you again for "&H"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

749 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