Link to home
Start Free TrialLog in
Avatar of jackjohnson44
jackjohnson44

asked on

VB6 Ohm symbol in label

I want to have both an ohms symbol and regular text in a label that I can change at run time.

Right now, I have to have two labels, one with words, one with an ohms symbol.

I can't find a way to have two fonts in the same label.

Also, after this happens, if a user does not have a font with the symbol font, will the ohms symbol
display incorrectly?

Avatar of vb_elmar
vb_elmar
Flag of Germany image

use the "symbol" font. -it is char no. 89


For r = 86 To 87

Label1.UseMnemonic = True

t = Timer: While Timer - t < 0.4
DoEvents
Wend

Label1.Caption = Chr(r)
Next
Label1.Font = "symbol"
Label1.FontSize = 33
Label1.FontBold = True
correction: it's char No. 87
Avatar of jackjohnson44
jackjohnson44

ASKER

I know how to get an ohms symbol, can I use two fonts in the same label?

also what happens if someone does not have symbol?
What font are you using for the words?  It may have a ohm character, try looking it up in the character map, under "Programs > Accessories > System Tools > Character Map".  Let me know what font you are using.
Hi jackjohnson44,

AFIK you cant do it using lables.

Try to use Richtexbox to show 2 different fonts in one line

RichTextBox1.Text = "This is regular text following by ohm symbol " & Chr(87)
RichTextBox1.SelStart = 45
RichTextBox1.SelLength = 1
RichTextBox1.SelFontName = "Symbol"
RichTextBox1.SelLength = 0


 
Michael D.
This page should take care of your problem.  You have to use a unicode font, (Again, these are listed under character map).  The following page tells you how to set up a unicode label, and how to insert all of the characters you need.  If you need any more help let me know.  Just for reference the unicode number for the omega symbol is 03A9.

The page is http://www.freevbcode.com/ShowCode.asp?ID=3591

I hope that I don't violate any rules for posting that link, however, I don't think it appropriate for me to take credit for the code by merely re-posting it here without giving credit for it.

I hope this helps.

thanks for the link, but I am a little confused.

Font.Name = "Arial Unicode MS"

does this set the font for the whole project to unicode?
I would think that it would have to be a property of something like
lable1.font.name

I do not want to have to change every label in my project to unicode.

Also, does the end user have to have unicode installed?
Yes, you can just change the font for the label, it doesn't have to be for the whole form.  What systems are you planning on this running on?  I know that the Arial Unicode font comes standard with windows 98 SE, windows 2000, and windows XP.  I don't have any other OS's in front of me to check on it.  Unless you include the font with the application however, I'm sure that the symbol would not show up.  You could always have your installer check for it and install it if the user does not have it.
edit to the last comment.  I said unless you include the font with the application it would not show up.  I meant that if they do not have it installed and you did not include it with your application it would not show up.  Anyone with win98se, win2k and winxp will have it installed with the Operating System.
Thanks for getting back to me.

I still don't understand what the "Font" tag is tied to.

Is it a parameter of the form? the scrollbar?

here is the form load taken from the site above

Private Sub Form_Load()
    ScrollBar1.Min = 33
    ScrollBar1.Max = 65533

    Font.Name = "Arial Unicode MS"
    Font.Size = 12

    ScrollBar1_Change
End Sub

I don't see how you can just say "Font" and it knows to only use it with the text box.

Thanks
I couldn't make this work either.

I changed the code and set  "Arial Unicode MS" to textBox's font property.
also I had to use UpDown controll instead of ScrollBar because scrollbar's Max Value is limited to 32767

Also Microsoft Forms 2.0 Object Library is part of MS Office and you cannot freely distribute it with your application.
 
another method:

instead of label put Picture box on the form:

Private Sub Form_Load()

Picture1.AutoRedraw = True
Picture1.Print "Regular text ";
Picture1.FontName = "Symbol"
Picture1.Print "W"

End Sub
BTW Symbol is system text and comes with ANY version of windows (starting from 3.x i guess)
Michael is right, the dll for the object library isn't distributable, but it can be downloaded freely as a free application from Microsoft by the end user.  I don't see why you couldn't perform a check when you install the program and then prompt them to download it.  I guess, there are a few different ways to do this, it would help if you could give us more background on what you are wanting to do.  Is there some reason a picture box as Michael described would not work?  There are a few activex control replacements on the web that you can buy that are unicode aware and will do what you ask.  Otherwise it looks like you'll have to do more programming to your installation routine.

As far as changing the label font, you can either do it in the properties of the label, or in code by :

label1.font = "Arial"


The example that I gave you did change the font for the entire form.  
I just realized what the problem was with Michael's response, you still have only one font, and he's using the symbol font which doesn't fix your original problem.    Are you trying to change what the label says via code, and the Omega symbol would have to move.  Thus you want it in one label, or just trying to clean up your form?
you still can change what lable says on runtime:

add Textbox and Button to you form

Fill textbox with any text then press the button - text will be shown in the picturebox followed by Ohm symbol

Private Sub Command1_Click()

Picture1.AutoRedraw = True
Picture1.Cls
Picture1.FontName = "Arial"
Picture1.Print Text1;
Picture1.FontName = "Symbol"
Picture1.Print "W"

End Sub
ASKER CERTIFIED SOLUTION
Avatar of Michael_D
Michael_D
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial