Results 1 to 22 of 22

Thread: richtext bold, simple question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Location
    Gent
    Posts
    166

    Question richtext bold, simple question

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Cn.Open "DSN=VAATLAB_OLD"
    4. SQL = "SELECT * FROM " & Pub_TestCode & " WHERE refnr = '" & Pub_Refnr & "'"
    5. Debug.Print SQL
    6. Rs.ActiveConnection = Cn
    7. Rs.Source = SQL
    8. Rs.Open
    9.  
    10. Tekst = "Test: " & Pub_Test & Chr(13) & Chr(10)
    11. Tekst = Tekst & "Patiënt: " & Rs.Fields.Item("patnaam").Value & Chr(9) & Chr(9) & "Adrema: " & Rs.Fields.Item("adrema").Value & Chr(13) & Chr(10)
    12. Tekst = Tekst & "Datum Onderzoek: " & Rs.Fields.Item("datond").Value & Chr(9) & Chr(9) & "refnr: " & Rs.Fields.Item("refnr").Value & Chr(13) & Chr(10)
    13. Tekst = Tekst & "Dienst: " & Rs.Fields.Item("dienst").Value & Chr(9) & Chr(9) & "Verdiep: " & Rs.Fields.Item("verdiep").Value & Chr(13) & Chr(10)
    14. Tekst = Tekst & "Aanvrager: " & Rs.Fields.Item("aanvrager").Value & Chr(13) & Chr(10)
    15. '---------------------------------------------------------------------------------------------------------------------------
    16. Tekst = Tekst & Chr(13) & Chr(10)
    17. Tekst = Tekst & "Arteria Illiaca Externa Rechts: " & Rs.Fields.Item("RE_IL_EXT").Value & Chr(13) & Chr(10)
    18. Tekst = Tekst & "Arteria Illiaca Externa Links: " & Rs.Fields.Item("LI_IL_EXT").Value & Chr(13) & Chr(10)
    19. Tekst = Tekst & "Arteria Femoralis Communis Rechts: " & Rs.Fields.Item("RE_FE_COM").Value & Chr(13) & Chr(10)
    20. Tekst = Tekst & "Arteria Femoralis Communis Links: " & Rs.Fields.Item("LI_FE_COM").Value & Chr(13) & Chr(10)
    21. Tekst = Tekst & "Arteria Femoralis Superficialis Prox. Rechts: " & Rs.Fields.Item("RE_FE_SUP_PRO").Value & Chr(13) & Chr(10)
    22. Tekst = Tekst & "Arteria Femoralis Superficialis Prox. Links: " & Rs.Fields.Item("LI_FE_SUP_PRO").Value & Chr(13) & Chr(10)
    23. Tekst = Tekst & "Arteria Femoralis Superficialis Mid. Rechts: " & Rs.Fields.Item("RE_FE_SUP_MID").Value & Chr(13) & Chr(10)
    24. Tekst = Tekst & "Arteria Femoralis Superficialis Mid. Links: " & Rs.Fields.Item("LI_FE_SUP_MID").Value & Chr(13) & Chr(10)
    25. Tekst = Tekst & "Arteria Femoralis superficialis - Kanaal van Hunter Rechts: " & Rs.Fields.Item("RE_HUNTER").Value & Chr(13) & Chr(10)
    26. Tekst = Tekst & "Arteria Femoralis superficialis - Kanaal van Hunter Links: " & Rs.Fields.Item("LI_HUNTER").Value & Chr(13) & Chr(10)
    27. Tekst = Tekst & "Arteria Poplitea Rechts: " & Rs.Fields.Item("RE_POP").Value & Chr(13) & Chr(10)
    28. Tekst = Tekst & "Arteria Poplitea Links: " & Rs.Fields.Item("LI_POP").Value & Chr(13) & Chr(10)
    29. Tekst = Tekst & "Truncus Tibio-pereonalis Rechts: " & Rs.Fields.Item("RE_TIB_PER").Value & Chr(13) & Chr(10)
    30. Tekst = Tekst & "Truncus Tibio-pereonalis Links: " & Rs.Fields.Item("LI_TIB_PER").Value & Chr(13) & Chr(10)
    31. Tekst = Tekst & "Arteria Tibialis Posterior Rechts: " & Rs.Fields.Item("RE_TIB_PO").Value & Chr(13) & Chr(10)
    32. Tekst = Tekst & "Arteria Tibialis Posterior Links: " & Rs.Fields.Item("LI_TIB_PO").Value & Chr(13) & Chr(10)
    33. Tekst = Tekst & "Arteria Tibialis Dorsalis Rechts: " & Rs.Fields.Item("RE_TIB_DORS").Value & Chr(13) & Chr(10)
    34. Tekst = Tekst & "Arteria Tibialis Dorsalis Links: " & Rs.Fields.Item("LI_TIB_DORS").Value & Chr(13) & Chr(10)
    35. Tekst = Tekst & "Opmerking: " & Rs.Fields.Item("opmerking").Value & Chr(13) & Chr(10)
    36. Tekst = Tekst & "beoordeling: " & Rs.Fields.Item("beoordeling").Value & Chr(13) & Chr(10)
    37.  
    38. RtxtTekst = Tekst
    39.  
    40. Cn.Close
    41.  
    42. End Sub

    I’d like to put the titles (like “Patiënt, “Arteria illiaca”, ..) in bold in the richtextbox. What is the best way to do this?

    thx in advance
    never argue with an idiot, he will bring you down to his level and will beat you through experience

  2. #2
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Exclamation Simple!

    Just add something like this:

    RichTextBox.TextRTF = RichTextBox.TextRTF & "{\b Patiënt\b0}"

    It would look like Patiënt

    The same is for the italic , underlined or striked fonts:

    Italic: "{\i Patiënt\i}"
    Underlined: "{\unline Patiënt\unline0}"
    Striked: "{\strike Patiënt\strike0}"

    You can also do the this:
    Bold and italic: "{\b\i Patiënt\b0\i0}"

    For more help just reply!
    Kostas Botonakis,Greece
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  3. #3
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    A good idea is to make some command buttons that changes the sel color, bolc etc. type something and save the file as an rtf to see the RTF syntax
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  4. #4
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Exclamation

    Yes that is a good idea VBNeo but not so simple and fast as my example.
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  5. #5
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Originally posted by DarkX_Greece
    Yes that is a good idea VBNeo but not so simple and fast as my example.
    Your example only covers 2 things in the syntax, this was more of a tip to richtext in general, your example(for example ), doesn't explain color tables, etc.
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    When adding "rich text", use the Sel??? (SelBold, SelText, SelColor etc) properties of the RichTextBox instead.

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.   Cn.Open "DSN=VAATLAB_OLD"
    4.   SQL = "SELECT * FROM " & Pub_TestCode & " WHERE refnr = '" & Pub_Refnr & "'"
    5.   Debug.Print SQL
    6.   Rs.ActiveConnection = Cn
    7.   Rs.Source = SQL
    8.   Rs.Open
    9.  
    10.   With RtxtTekst
    11.       .SelBold = True : .SelText = "Patiënt: "
    12.       .SelBold = False : .SelText = Rs.Fields.Item("patnaam").Value & Chr(9) & Chr(9) & "Adrema: " & Rs.Fields.Item("adrema").Value & Chr(13) & Chr(10)
    13.  
    14.       .SelBold = True : .SelText = "Arteria Illiaca Externa Rechts: "
    15.       .SelBold = False: .SelText = Rs.Fields.Item("RE_IL_EXT").Value & Chr(13) & Chr(10)
    16.  
    17.   End With
    18.   Cn.Close
    19. End Sub

  7. #7
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    the Sel functions really aren't reliable, and editing the RTF is more 'stable'(hell, the Sel functions are at least as unstable as plutonium)
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  8. #8
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Exclamation Easier but not reliable

    Yes i know that sel functions of rich text box are easier and faster than editing the RTF text but it is not reliable, u may have many problems. Try editing the RTF Text as my first example.VBNeo , for color formating your example is very nice but for font formating is not.

    Italic: "{\i " & your text here & "\i0}"
    Bold: "{\b " & your text here & "\b0}"
    Strikethrough: "{\strike " & your text here & "\strike0}"
    Underlined: "{\uline " & your text here & "\uline0}"
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  9. #9
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    Re: Easier but not reliable

    Originally posted by DarkX_Greece
    Yes i know that sel functions of rich text box are easier and faster than editing the RTF text but it is not reliable, u may have many problems. Try editing the RTF Text as my first example.VBNeo , for color formating your example is very nice but for font formating is not.

    Italic: "{\i " & your text here & "\i0}"
    Bold: "{\b " & your text here & "\b0}"
    Strikethrough: "{\strike " & your text here & "\strike0}"
    Underlined: "{\uline " & your text here & "\uline0}"
    If so, tell me how to change the size and font of a particular line of text(without peaking in an RTF file)
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  10. #10
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Exclamation Very easy!!!!!!!!!!!!!!!!!!!!!

    Well look at this:

    fs16 = Font size 8
    fs24 = Font size 12
    fs28 = Font size 14
    fs32 = Font size 16
    fs72 = Font size 36
    fs144 = Font size 72

    If you can see are double!
    Here is an example code

    RichTextBox1.TextRTF = RichTextBox1.TextRTF & "{\fs144 Test\cf0\fs24}

    This example will show you this:



    Test


    it has font size 72.

    Need more in rich text box? Just send a message
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  11. #11
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    Re: Very easy!!!!!!!!!!!!!!!!!!!!!

    Originally posted by DarkX_Greece
    Well look at this:

    fs16 = Font size 8
    fs24 = Font size 12
    fs28 = Font size 14
    fs32 = Font size 16
    fs72 = Font size 36
    fs144 = Font size 72

    If you can see are double!
    Here is an example code

    RichTextBox1.TextRTF = RichTextBox1.TextRTF & "{\fs144 Test\cf0\fs24}

    This example will show you this:



    Test


    it has font size 72.

    Need more in rich text box? Just send a message
    hehe, touché - but, it still doesn't change the fact that it's easier for a someone who doesn't know the syntax in his head to make an RTF file and look, than posting here...
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Location
    Gent
    Posts
    166
    thanks people, thanks for the advice, i'm going to try both options...

    thanks a lot
    never argue with an idiot, he will bring you down to his level and will beat you through experience

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Location
    Gent
    Posts
    166
    Private Sub Form_Load()

    Cn.Open "DSN=VAATLAB_OLD"
    SQL = "SELECT * FROM " & Pub_TestCode & " WHERE refnr = '" & Pub_Refnr & "'"
    Debug.Print SQL
    Rs.ActiveConnection = Cn
    Rs.Source = SQL
    Rs.Open

    Dim test As String
    Me.Caption = Pub_Test

    tekst = "Test: " & Pub_Test & Chr(13) & Chr(10)
    tekst = tekst & "Patiënt: " & Rs.Fields.Item("patnaam").Value & Chr(9) & Chr(9) & "Adrema: " & Rs.Fields.Item("adrema").Value & Chr(13) & Chr(10)
    tekst = tekst & "Datum Onderzoek: " & Rs.Fields.Item("datond").Value & Chr(9) & Chr(9) & "refnr: " & Rs.Fields.Item("refnr").Value & Chr(13) & Chr(10)
    tekst = tekst & "Dienst: " & Rs.Fields.Item("dienst").Value & Chr(9) & Chr(9) & "Verdiep: " & Rs.Fields.Item("verdiep").Value & Chr(13) & Chr(10)
    tekst = tekst & "Aanvrager: " & Rs.Fields.Item("aanvrager").Value & Chr(13) & Chr(10)
    '---------------------------------------------------------------------------------------------------------------------------
    tekst = tekst & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Illiaca Externa Rechts: " & Rs.Fields.Item("RE_IL_EXT").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Illiaca Externa Links: " & Rs.Fields.Item("LI_IL_EXT").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis Communis Rechts: " & Rs.Fields.Item("RE_FE_COM").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis Communis Links: " & Rs.Fields.Item("LI_FE_COM").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis Superficialis Prox. Rechts: " & Rs.Fields.Item("RE_FE_SUP_PRO").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis Superficialis Prox. Links: " & Rs.Fields.Item("LI_FE_SUP_PRO").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis Superficialis Mid. Rechts: " & Rs.Fields.Item("RE_FE_SUP_MID").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis Superficialis Mid. Links: " & Rs.Fields.Item("LI_FE_SUP_MID").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis superficialis - Kanaal van Hunter Rechts: " & Rs.Fields.Item("RE_HUNTER").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Femoralis superficialis - Kanaal van Hunter Links: " & Rs.Fields.Item("LI_HUNTER").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Poplitea Rechts: " & Rs.Fields.Item("RE_POP").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Poplitea Links: " & Rs.Fields.Item("LI_POP").Value & Chr(13) & Chr(10)
    tekst = tekst & "Truncus Tibio-pereonalis Rechts: " & Rs.Fields.Item("RE_TIB_PER").Value & Chr(13) & Chr(10)
    tekst = tekst & "Truncus Tibio-pereonalis Links: " & Rs.Fields.Item("LI_TIB_PER").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Tibialis Posterior Rechts: " & Rs.Fields.Item("RE_TIB_PO").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Tibialis Posterior Links: " & Rs.Fields.Item("LI_TIB_PO").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Tibialis Dorsalis Rechts: " & Rs.Fields.Item("RE_TIB_DORS").Value & Chr(13) & Chr(10)
    tekst = tekst & "Arteria Tibialis Dorsalis Links: " & Rs.Fields.Item("LI_TIB_DORS").Value & Chr(13) & Chr(10)
    tekst = tekst & "Opmerking: " & Rs.Fields.Item("opmerking").Value & Chr(13) & Chr(10)
    tekst = tekst & "beoordeling: " & Rs.Fields.Item("beoordeling").Value & Chr(13) & Chr(10)

    RtxtTekst = tekst
    Debug.Print RtxtTekst.TextRTF
    RtxtTekst.TextRTF = RtxtTekst.TextRTF & "{\b Patiënt\b0}"
    Debug.Print RtxtTekst.TextRTF

    Cn.Close

    End Sub

    DarkX_Greece, if the tip you gave me would work this would be the best way to change the font of a richtextfield... i must be doing something wrong however...

    Debug.print gives me back the same string???
    never argue with an idiot, he will bring you down to his level and will beat you through experience

  14. #14
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    1. use code tags to paste ur code.

    it becomes more readable

    like this:

    VB Code:
    1. 'code goes here

    2. What does Debug.print give you, the entire text of RtxtTekst + the patient line?

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Location
    Gent
    Posts
    166
    Code:
    test
    ?

    tried it a few times...look at the original post...i wanted to do it the right way...

    after the second debug.print the line "{\b Patiënt\b0}" can't be found in RtxtTekst.TextRTF...

    thanx
    never argue with an idiot, he will bring you down to his level and will beat you through experience

  16. #16
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim t As String
    3.     t = "{\par \b Patient\b0:" & "  Patient Name\par}" 'Marks the begining of the new paragraph - then u dont need chr(13)....
    4.     RichTextBox1.TextRTF = t
    5.     Debug.Print t 'prints - {\par \b Patient\b0:  Patient Name\par}
    6. End Sub

  17. #17
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    A simple, but slow method would be:

    VB Code:
    1. Private Sub Form_Load()
    2.     RichTextBox1.SelBold = True
    3.     RichTextBox1.SelText = "Patient :"
    4.     RichTextBox1.SelStart = Len(RichTextBox1.Text)
    5.     RichTextBox1.SelBold = False
    6.     RichTextBox1.SelText = vbTab & " patient Name"
    7. End Sub

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Nov 2003
    Location
    Gent
    Posts
    166
    that's one way to do it indeed... but since i have to repeat this code for 10 times with different values i'd like to do it the easy way.

    DarkX_Greece gave me an excellent example of how it can be done, and i really want to find out what i'm doing wrong because i think i'll be using his tip a lot in the future... if it works off course...

    greetz
    never argue with an idiot, he will bring you down to his level and will beat you through experience

  19. #19
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    You mean the one with the RTF tags?

  20. #20
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    VB Code:
    1. Tekst = Tekst & "{\par \b Patiënt: \b0 \tab " & "Add as many fields here"
    2.     Tekst = Tekst & "{\par \b Datum Onderzoek: \b0 \tab " & "Second line of fields \par}"
    3. 'Finally close the tag
    4.     Tekst = Tekst & "\par}"
    5.     RichTextBox1.TextRTF = Tekst

    Does this Help?

  21. #21
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Exclamation

    Well, i gave you the example how to use the rtf tags. It is a very easy way to do it.
    Look an example:

    'Function that shows how to add a Bold word or sentense in
    'a Rich Text Box
    Function AddBoldWord (strWord as String)
    'Check if strWord is = null
    If strWord = "" then
    'If null then stop
    Exit Function
    End If
    'Add the bold word or sentence in the Rich Text Box.
    RichTextBox1.TextRTF = RichTextBox1.TextRTF & "\par\b " & _
    strWord & "\b0\par"
    End Function


    It will show you something like this: BOLD WORD

    If you need something more about Rich Text Box tags, just send a message in the forum or

    My Email: [email protected]
    My MSN ID: [email protected]
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  22. #22
    Junior Member
    Join Date
    Jan 2004
    Posts
    25
    Originally posted by veryjonny
    VB Code:
    1. Tekst = Tekst & "{\par \b Patiënt: \b0 \tab " & "Add as many fields here"
    2.     Tekst = Tekst & "{\par \b Datum Onderzoek: \b0 \tab " & "Second line of fields \par}"
    3. 'Finally close the tag
    4.     Tekst = Tekst & "\par}"
    5.     RichTextBox1.TextRTF = Tekst

    Does this Help?
    It helped me. Thanks, John.

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