Results 1 to 16 of 16

Thread: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    74

    Resolved [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form



    Hi, Do anyone know how to insert:

    1) symbol :Eg: α, β (alpha and beta) and more...

    2) Subscript and superscript?

    3) last but not least a professional mathematics equation?

    into the interface (with label or anything) of the VB program

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to insert symbol, subscript, superscripts and mathematics equation in VB form

    you can use equation editor in an ole object
    check out http://www.dessci.com/en/products/ee...htm#other_apps
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Removed due to double post.
    Last edited by CDRIVE; Jan 26th, 2009 at 04:28 PM. Reason: Double post
    <--- 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??

  4. #4
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: How to insert symbol, subscript, superscripts and mathematics equation in VB form

    I like what Westconn1 suggested as it seems quite powerful. If you decide to build from scratch then the Chr(n) function returns the ASCII chr. The Symbol font has many of the fonts you need and it's what I used in this example.

    Code:
    Option Explicit
    
    ' Set Text1.Multiline = True in the Properties window
    Private Sub Form_Load()
       Dim i As Integer
       Form1.WindowState = vbMaximized
       Form1.Show
       With Text1
          .Font = "Symbol"
          .FontSize = 14
          .FontBold = True
          .Text = ""
          .Height = Form1.Height
          .Width = Form1.Width
          .Left = Form1.Left
          .Top = Form1.Top
       End With
       
        For i = 1 To 255
             Text1.Text = Text1.Text & Chr(i)
          Next i
    End Sub
    <--- 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??

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    74

    Re: How to insert symbol, subscript, superscripts and mathematics equation in VB form

    thanks I got it...

  6. #6
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    CDRIVE

    Love your loop idea

    I use CharacterMap alot (the program that comes with Windows),
    but it is kind of a pain to mentally translate the Hex designation
    to a numeric (1-255) designation. I could see one creating a companion
    app using your loop idea to enable a mouseover to return a numeric
    value for use with the Chr function.

    Spoo

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    I could see one creating a companion
    app using your loop idea to enable a mouseover to return a numeric
    value for use with the Chr function.
    i have been using a small app like that (not mouseover, but cursor position) to find any non printing characters in any string, displays the ascii value in separate textbox
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Spoo, you might like this. I wrote it some time ago when all my variables used type symbol designators. Set the TextBox to Multiline. The program uses 1 TextBox, 3 ListBoxes and 1 CheckBox. List1 holds all the Fonts Collection, List2 holds Font size and List3 holds the range of Chr(n) to loop through. Check3 selects whether or not the Chr Code is displayed next to the ASCII char. Too lazy to zip this!
    Edit: Just realized that there's only one named variable!
    Code:
    Option Explicit
    Dim i%
    
    Private Sub Check3_Click()
       DisplayChrCodeYesNo
    End Sub
    
    Private Sub Form_Load()
       Show
       Check3.Caption = "Show Char Code"
       List1.Height = Me.Height - 3000
       Text1.Width = 12400
          For i = 8 To 20
             List2.AddItem i
          Next
             List2.ListIndex = 0
          For i = 0 To Screen.FontCount - 1
             List1.AddItem Screen.Fonts(i)
          Next
             List1.ListIndex = 0
                List3.AddItem "ChrCodes 1 To 128"
             List3.AddItem "ChrCodes 128 To 255"
          List3.AddItem "ChrCodes 1 To 255"
       List3.ListIndex = 0
    End Sub
    
    Private Sub List1_Click()
       DisplayChrCodeYesNo
    End Sub
    
    Private Sub List2_Click()
       Text1.FontSize = List2.List(List2.ListIndex)
    End Sub
    
    Private Sub DisplayChrCodeYesNo()
       Text1.Text = ""
       Text1.FontName = List1.List(List1.ListIndex)
       If List3.ListIndex = 0 Then
          For i% = 1 To 128
             If Check3.Value = vbChecked Then
                Text1.Text = Text1.Text & "Chr" & i% & "= " & Chr(i%) & "  "
             Else
                Text1.Text = Text1.Text & Chr(i%) & "  "
             End If
          Next
       End If
          If List3.ListIndex = 1 Then
             For i% = 128 To 255
                If Check3.Value = vbChecked Then
                   Text1.Text = Text1.Text & "Chr" & i% & "= " & Chr(i%) & "  "
                Else
                   Text1.Text = Text1.Text & Chr(i%) & "  "
                End If
             Next
          End If
             If List3.ListIndex = 2 Then
          For i% = 1 To 255
             If Check3.Value = vbChecked Then
                Text1.Text = Text1.Text & "Chr" & i% & "= " & Chr(i%) & "  "
             Else
                Text1.Text = Text1.Text & Chr(i%) & "  "
             End If
          Next
       End If
    End Sub
    
    Private Sub List3_Click()
       DisplayChrCodeYesNo
    End Sub
    Last edited by CDRIVE; Jan 26th, 2009 at 06:11 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??

  9. #9
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Quote Originally Posted by westconn1
    i have been using a small app like that (not mouseover, but cursor position) to find any non printing characters in any string, displays the ascii value in separate textbox
    West, are you going to post 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??

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    will do later, from my computer, but it is a pretty simple thing i did some time ago
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  11. #11
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    CDRIVE

    Nice. Thanks... will check out later (kinda in the middle of something right now).

    Spoo

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    74

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Hi i had tried the using equation editor in an ole object

    but the symbol is too big in size and the subscript and superscript is too far from the letter.

    Is there any method of control the font size?

  13. #13
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Quote Originally Posted by greatgerd
    Hi i had tried the using equation editor in an ole object

    but the symbol is too big in size and the subscript and superscript is too far from the letter.

    Is there any method of control the font size?
    Are you referring to the editor that Westconn1 supplied a link to?
    <--- 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??

  14. #14
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Hi i had tried the using equation editor in an ole object

    but the symbol is too big in size and the subscript and superscript is too far from the letter.

    Is there any method of control the font size?
    i would suggest using equation editor in word, to start, till you find out what some of the options are, you can change sizes for super and subscripts, also change kerning to move things closer together also define new sizes
    if you are using similar equations regularly you can save in a word document or similar then just copy to your app
    you can also change spacing by rescaling the object, by width or height
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    74

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    Yep I am reffering to WestConn pete reply.
    I don't know much about VB6, So I choose the easy method hehe..
    I am using Microsoft Office 2007. so Mic. Words is different.I can't edit anyting.

    but I still can use Mic.Publisher to do the editting and kerning.
    Thanks a lot

  16. #16
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] How to insert symbol, subscript, superscripts and mathematics equation in VB form

    @ cdrive
    West, are you going to post it?
    decided to post to codebank, rather than in this thread http://www.vbforums.com/showthread.p...50#post3431550
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width