I'm writing a program that will involve displaying electronics formulas. I would like to display the formulas in an accepted format familiar to students. Does anyone know of a font that would return the chr(codes) that I would need to produce Sq Roots, Pi, Sci/Eng Notation etc?
Example:
Code:
Text1 = " 3 x " & "10" & Chr(179) 'Returns 3 x 10³
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Thanks Anhn, but that's a huge file (22MB) for just fonts and I'm not sure it's what I'm looking for. Most symbols can be found in the font selection provided in VB. What I want the most is exponents.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Probably this is the best suit for you without any add-on:
With font "Palatino Linotype" (a standard font for any Windows system):
You can have Chr$(185)="¹", Chr$(178)="²" and Chr$(179)="³",
plus many more in range &H2010 - &H237A.
Do the same as before, copy characters below, paste in Word then change font to "Palatino Linotype", you can see more symbols
Probably this is the best suit for you without any add-on:
With font "Palatino Linotype" (a standard font for any Windows system):
You can have Chr$(185)="¹", Chr$(178)="²" and Chr$(179)="³",
plus many more in range &H2010 - &H237A.
Sorry for the long delay in responding but I wanted to be certain of what my response was going to be. Well Palatino Linotype will not produce the exponents that I need. I must be able to produce exponents from 10 to the minus 12th to 10 to the 12th power.
When working in Word it's a totally different ball game, as Word (even my old 97 version) provides the nifty Superscript & Subscript functions. This feature lets the user manipulate letters and numbers in accepted IEEE format, nearly regardless of the FontName used. If I could import or code that kind of flexibility into VB I would be a very happy camper indeed!
Thank you for your effort, but I'm still stuck in an exponent quagmire. I've spent endless hours Googling for a solution to no avail.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Never tried it before so I might be talking rubbish but can't you insert a Word object?
No, you're not talking rubbish. A Word Doc most certainly can be embedded, but I don't want to do that. I find it very frustrating not to be able to print exponents to the Form, TextBoxes or Labels. That said, I may find that I have no choice. Grrrrr!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
I'm writing a program that will involve displaying electronics formulas. I would like to display the formulas in an accepted format familiar to students. Does anyone know of a font that would return the chr(codes) that I would need to produce Sq Roots, Pi, Sci/Eng Notation etc?
Example:
Code:
Text1 = " 3 x " & "10" & Chr(179) 'Returns 3 x 10³
That is totally different approaches. In Word, it uses formatting to produce subscript or supperscript.
Here, it is plain text as you asked for the font that can give supperscript (exponent) and Sci notation.
You may use RTB that allows you to format text or use a control that can support Unicode.
Standard controls in VB6 does not support Unicode.
Search Codebank you can find Unicode controls from Merri.
Don't forget to use [CODE]your code here[/CODE] when posting code
If your question was answered please use Thread Tools to mark your thread [RESOLVED]
You may use RTB that allows you to format text or use a control that can support Unicode.
Standard controls in VB6 does not support Unicode.
Search Codebank you can find Unicode controls from Merri.
Okay Anhn, I will check it out. BTW do you know when MS first included Ariel Unicode MS in Word, because my Office 97 doesn't include it.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Forget about Arial Unicode MS, this is the largest font from MS (I am not sure but probably it was added in 2002).
Make sure you have the Unicode version of Palatino Linotype.
If you can use Arial Unicode MS then you can use Palatino Linotype (this is much smaller).
I think Office 97 does not support Unicode (or does not fully support).
Last edited by anhn; Jun 19th, 2008 at 08:35 PM.
Don't forget to use [CODE]your code here[/CODE] when posting code
If your question was answered please use Thread Tools to mark your thread [RESOLVED]
Make sure you have the Unicode version of Palatino Linotype.
If you can use Arial Unicode MS then you can use Palatino Linotype (this is much smaller).
I think Office 97 does not support Unicode (or does not fully support).
I have Palatino Linotype but I have no idea if it's the Unicode version?
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Consider using a webbrowser control to display a web page. Web page will contain formula formatted with HTML+CSS.
Thanks leinad but if I go that rout I might as well just embed a word doc. I'm beginning to feel like a stubborn PITA!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
I have Palatino Linotype but I have no idea if it's the Unicode version?
Palatino Linotype is one of Microsoft Windows standard fonts (comes with Time New Roman, Tahoma, Verdana, ...), I think it must be Unicode unless you use too old Windows version (98 or earlier).
Use Character Map from Accessories you can view all available characters.
Don't forget to use [CODE]your code here[/CODE] when posting code
If your question was answered please use Thread Tools to mark your thread [RESOLVED]
If u just want to display, u can use a function that generate a label with the required exponent, and position it just next to the base
This may seem obvious to you, but not to me. Would you like to post an example?
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Palatino Linotype is one of Microsoft Windows standard fonts (comes with Time New Roman, Tahoma, Verdana, ...), I think it must be Unicode unless you use too old Windows version (98 or earlier).
Use Character Map from Accessories you can view all available characters.
Actually, I wrote a little utility to do that.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Why bother to do that unless it will be used in your project.
Do what?
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Oh that! I wrote that utility some time ago just because I could.
BTW, I think this issue is resolved as I've discovered that a RTB will support Superscripts & Subscripts. I've not worked with RTB much so I need to get my feet good and wet! I'm sure I'll be asking some questions.
I've also found that I can paste a numeric value (that's been Superscripted in Word) into a RTB and it retains its formatting. So I'm assuming that if I write the formatted text in Word and then input it as a file to a RTB, that will work also.... I think? Admittedly, I've never inputted a .doc before. Can it be done?
Last edited by CDRIVE; Jun 20th, 2008 at 12:09 PM.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
OK, I tried this and it doesn't retain the formatting. I also saved the Doc as a .RTF and the Input results were even worse.
Code:
Option Explicit
Dim MyChar$
Private Sub Command1_Click()
RTB.Height = Me.Height
RTB.Width = Me.Width
ChDir ("C:\Documents and Settings\Owner\Desktop")
' Open "24x10.rtf" For Input As 1#
Open "24x10.doc" For Input As 1#
Do While Not EOF(1) ' Loop until end of file.
MyChar$ = Input(1, #1) ' Get one character at a time.
Text1.Text = Text1.Text & MyChar$
RTB.Text = RTB.Text & MyChar$
Loop
Close #1 ' Close file.
End Sub
So I will either directly code Superscript & Subscript to the RTB or I will give in and embed a Word Doc in my app. In retrospect, I think embedding is the easiest solution.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
RTB.Text is text only, you want RTB.RTFText (I think) which contains text and formatting.
I thought I tried that but let my try it again.
Thanks
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
BTW, I think this issue is resolved as I've discovered that a RTB will support Superscripts & Subscripts. I've not worked with RTB much so I need to get my feet good and wet! I'm sure I'll be asking some questions.
That is what I said in post#8. It takes you so long to discover.
Don't forget to use [CODE]your code here[/CODE] when posting code
If your question was answered please use Thread Tools to mark your thread [RESOLVED]
That is what I said in post#8. It takes you so long to discover.
Anhn you've hung in there throughout this rather long and laborious thread like a good soldier. I'm going to claim a senior moment! How I missed that comment in post 8, I don't know? My humble apologies!!
Thank you for staying with me.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
RTB.Text is text only, you want RTB.RTFText (I think) which contains text and formatting.
Si, I gave it another try, just to make sure that I didn't miss something. My results were the same; no visible input to the RTB. Unless I read it wrong, the MSDN library info on the TextRTF property states that it's used to Output RTF to a RTF file.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Here is a sample project which print exponents on a label
Amr Al-Amr, thanks for the zip file. It's a novel approach. That said, it would be an exceedingly tedious task to write copious amounts of exponents in that fashion.
I'm going to keep this file though, as it's very clever!!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
Si, I gave it another try, just to make sure that I didn't miss something. My results were the same; no visible input to the RTB. Unless I read it wrong, the MSDN library info on the TextRTF property states that it's used to Output RTF to a RTF file.
Nope.. it is read and write. Here is what I see in MSDN (as usual, the first part gives the overview, and the Remarks section gives comments/examples/exceptions):
Returns or sets the text of a RichTextBox control, including all .rtf code.
Syntax
....
Remarks
Setting the TextRTF property replaces the entire contents of a RichTextBox control with the new string.
You can use the TextRTF property along with the Print function to write .rtf files. The resulting file can be read by any other word processor capable of reading RTF-encoded text.
While the last sentence gives one example of a way you can use it, that is certainly not the only thing you can do with it.
I created a simple .RTF file with part of it in superscript, and it displayed perfectly with either of these methods:
Code:
Me.RichTextBox1.LoadFile "c:\folder\file.rtf"
Code:
'Load entire file into string
Dim intFileNum As Integer, strFile As String
intFileNum = FreeFile
Open "c:\temp\superscript.rtf" For Binary As #intFileNum
strFile = Space(LOF(intFileNum))
Get #intFileNum, , strFile
Close #intFileNum
'put it into the control
Me.RichTextBox1.TextRTF = strFile
To write directly to the control in superscript, you can use code like this:
Code:
With Me.RichTextBox1
.Font.Name = "Arial"
.Font.Size = 8
.Text = "103!"
.SelStart = 2 'select just the "3"
.SelLength = 1
.SelFontSize = 6 'size of the superscript text
.SelCharOffset = 5 * Screen.TwipsPerPixelX 'height above the baseline
.SelStart = 0
.SelLength = 0
End With
Si, I hesitated before marking this post resolved and now I know why. I have family in from out of town so I'll have to run your code later. Not that it will make any difference, but the file I was inputting was a doc that I saved as .RTF. Like I said, I doubt that that has anything to do with why it failed on me. Inputting as Binary is the key, I'm sure.
Thanks for the code. I'll let you know how it works out.
EDIT: Ran my mouth to soon! I ran the top example and it worked perfectly! Nothing to do with Binary! Thanks again Si!
Last edited by CDRIVE; Jun 21st, 2008 at 11:30 AM.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
OK Si, I ran all your code and (no surprise) they all ran splendidly! I almost posted an 'Except for:' I kept getting an exclamation point in your With block. Do you know that the"!" typo is there?
Thanks heaps Si!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??