Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb.NET characters

Posted on 2004-09-20
8
Medium Priority
?
1,781 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
[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
  • 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 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

610 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