|
-
Feb 4th, 2004, 05:09 AM
#1
Thread Starter
Addicted Member
richtext bold, simple question
VB Code:
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
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
Cn.Close
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
-
Feb 4th, 2004, 06:25 AM
#2
Hyperactive Member
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
-
Feb 4th, 2004, 08:32 AM
#3
Frenzied Member
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.
-
Feb 4th, 2004, 10:19 AM
#4
Hyperactive Member
Yes that is a good idea VBNeo but not so simple and fast as my example.
-
Feb 4th, 2004, 10:21 AM
#5
Frenzied Member
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.
-
Feb 4th, 2004, 11:36 AM
#6
When adding "rich text", use the Sel??? (SelBold, SelText, SelColor etc) properties of the RichTextBox instead.
VB Code:
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
With RtxtTekst
.SelBold = True : .SelText = "Patiënt: "
.SelBold = False : .SelText = Rs.Fields.Item("patnaam").Value & Chr(9) & Chr(9) & "Adrema: " & Rs.Fields.Item("adrema").Value & Chr(13) & Chr(10)
.SelBold = True : .SelText = "Arteria Illiaca Externa Rechts: "
.SelBold = False: .SelText = Rs.Fields.Item("RE_IL_EXT").Value & Chr(13) & Chr(10)
End With
Cn.Close
End Sub
-
Feb 4th, 2004, 11:37 AM
#7
Frenzied Member
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.
-
Feb 4th, 2004, 12:09 PM
#8
Hyperactive Member
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}"
-
Feb 4th, 2004, 12:17 PM
#9
Frenzied Member
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.
-
Feb 4th, 2004, 12:34 PM
#10
Hyperactive Member
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
-
Feb 4th, 2004, 04:12 PM
#11
Frenzied Member
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.
-
Feb 5th, 2004, 03:15 AM
#12
Thread Starter
Addicted Member
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
-
Feb 6th, 2004, 02:48 AM
#13
Thread Starter
Addicted Member
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
-
Feb 6th, 2004, 03:58 AM
#14
PowerPoster
1. use code tags to paste ur code.
it becomes more readable
like this:
2. What does Debug.print give you, the entire text of RtxtTekst + the patient line?
-
Feb 6th, 2004, 04:27 AM
#15
Thread Starter
Addicted Member
?
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
-
Feb 6th, 2004, 04:46 AM
#16
PowerPoster
VB Code:
Private Sub Form_Load()
Dim t As String
t = "{\par \b Patient\b0:" & " Patient Name\par}" 'Marks the begining of the new paragraph - then u dont need chr(13)....
RichTextBox1.TextRTF = t
Debug.Print t 'prints - {\par \b Patient\b0: Patient Name\par}
End Sub
-
Feb 6th, 2004, 04:51 AM
#17
PowerPoster
A simple, but slow method would be:
VB Code:
Private Sub Form_Load()
RichTextBox1.SelBold = True
RichTextBox1.SelText = "Patient :"
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SelBold = False
RichTextBox1.SelText = vbTab & " patient Name"
End Sub
-
Feb 6th, 2004, 05:02 AM
#18
Thread Starter
Addicted Member
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
-
Feb 6th, 2004, 05:06 AM
#19
PowerPoster
You mean the one with the RTF tags?
-
Feb 6th, 2004, 05:13 AM
#20
PowerPoster
VB Code:
Tekst = Tekst & "{\par \b Patiënt: \b0 \tab " & "Add as many fields here"
Tekst = Tekst & "{\par \b Datum Onderzoek: \b0 \tab " & "Second line of fields \par}"
'Finally close the tag
Tekst = Tekst & "\par}"
RichTextBox1.TextRTF = Tekst
Does this Help?
-
Feb 6th, 2004, 05:33 AM
#21
Hyperactive Member
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]
-
Mar 14th, 2004, 06:47 AM
#22
Junior Member
Originally posted by veryjonny
VB Code:
Tekst = Tekst & "{\par \b Patiënt: \b0 \tab " & "Add as many fields here"
Tekst = Tekst & "{\par \b Datum Onderzoek: \b0 \tab " & "Second line of fields \par}"
'Finally close the tag
Tekst = Tekst & "\par}"
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|