• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

How to transfer 5 text boxes to 1 RTFbox and 1 of them in Italic?

I need to select a text in RTF text box in order to afterwards make that selection in italic.
My idea is to have like 5 text boxes, all will be toghether, but box number 3 will be italic.
Each time I click Insert button, an RTF box will have Box1 & box2 & box3... but number 3 is in italic.
Anyone can help me?

This is the code I've tried:

Private Sub Insert_Click()
italicfinder$ = txt3.Text
newline$ = Chr(13) + Chr(10)
frmMain.rtfBox.Text = frmMain.rtfBox.Text & txt2.Text & "." & txt3.Text & txt4.Text & txt5.Text & newline$
Dim foundpos As Integer
foundpos = frmMain.rtfBox.Find(italicfinder$, , , rtfWholeWord)
If foundpos <> -1 Then
frmMain.rtfRefs.Span " ", True, True
frmMain.rtfRefs.SelBold = True
Else
MsgBox "Not found"
End If
End Sub

This doesn't work.
Maybe there is another way to have those in the RTFBox and each time i click insert more will go into the new line (always with textbox 3 italic)

Thanks to everyone!
0
Shaolao
Asked:
Shaolao
  • 3
1 Solution
 
Da_WeaselCommented:
When adding txt3.Text to the rtfBox put a space infront and behind it if you are going to use rtfWholeWord option.
0
 
SmashmadCommented:
Dont yo said Italic? why do you write
frmMain.rtfRefs.SelBold = True
it is:
frmMain.rtfRefs.SelItalic = True
0
 
SmashmadCommented:
Dont yo said Italic? why do you write
frmMain.rtfRefs.SelBold = True
it is:
frmMain.rtfRefs.SelItalic = True
0
 
SmashmadCommented:
My RichTextBox is called Rich
Text1, text2, text3, text4, text5 are the textBoxes
I use seltext, so i dont erase the old format..
Try it:

'--------------------------
Dim n As Integer
Rich.SelStart = Len(Rich.Text)
Rich.SelText = Text1 & Text2 & "."
n = Len(Rich.Text)
Rich.SelStart = n
Rich.SelText = Text3 & Text4 & Text5 & vbCrLf

Rich.SelStart = n
Rich.SelLength = Len(Text3)
Rich.SelItalic = True
Rich.SelLength = 0 'quit this line if yo want text3 selected
0
 
ShaolaoAuthor Commented:
It works perfectly.
I've tried an implementation like this one before but I didn't get it to work. Thank you!
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now