Solved

vb.NET characters

Posted on 2004-09-20
8
1,655 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now