vb.NET characters

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?
Dan-KeyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
RonaldBiemansConnect With a Mentor Commented:
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
 
fulscherCommented:
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
 
RonaldBiemansCommented:
Just look in the character map and convert the code from hex to integer
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
Dan-KeyAuthor Commented:
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
 
fulscherCommented:
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
 
RonaldBiemansConnect With a Mentor Commented:
- 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
 
fulscherCommented:
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
 
Dan-KeyAuthor Commented:
Thanks to both of you.
fulscher, thank you again for "&H"
0
All Courses

From novice to tech pro — start learning today.