|
-
May 15th, 2011, 04:04 AM
#1
Thread Starter
New Member
Rich text Box cursor set.
Good Morning All.
Just learning VB and would like Help
I have set up a program with four Rich text Boxes and two command buttons.
Rich text boxes 1and 3 call external RTF files, Command 1 copying the contents of Rich text box 1 to the clip board and pastes in to rich text box 2.
' Selects and copies the text from Rich Text Box 1 to the Clipboard
Clipboard.SetText RichTextBox1.Text
'Paste Clipboard selection to Rich Text Box 2
RichTextBox2.Text = Clipboard.GetText
Then Command 2 does the same for the other text boxes.
However what I would like to do is set the cursor / focus to the end of the copied text (say into RichTextBox2) so that I can the paste another selection of text below what is already there. (After the pasted text in RichTextBox2)
Hope that this makes sense and that someone can help.
Cheers
Scott Pattison
Last edited by ScottPattison; May 15th, 2011 at 04:56 AM.
-
May 15th, 2011, 07:31 AM
#2
Re: Rich text Box cursor set.
You can do one of two things:
RichTextBox1.SelStart = Len(RichTextBox1.Text)
or
RichTextBox1.Text = RichTextBox1.Text & "blah"
-
May 15th, 2011, 08:48 AM
#3
Thread Starter
New Member
Re: Rich text Box cursor set.
Not sure where to put this.
Could you put the idiots guide.
Thanks
Scott
-
May 15th, 2011, 08:56 AM
#4
Re: Rich text Box cursor set.
Sorry but I don't have enough information to tell you exactly where to put it. All I can say is that if you have text in, say, RichTextBox1 and you want to paste text at the end of what's there you would do
RichTextBox1.Text = RichTextBox1.Text & a-variable-containing-the-new-text
or
RichTextBox1.Text = RichTextBox1.Text & Clipboard.GetText()
and you would put the code in the routine where you want to do the code addition.
However if you want to type text into the rtb then you would use the selstart code.
-
May 15th, 2011, 09:07 AM
#5
Thread Starter
New Member
Re: Rich text Box cursor set.
Private Sub Command1_Click()
' This is the code for the first command button, output pasted to richtextbox2
' Selects and copies the text from Rich Text Box 1 to the Clipboard
Clipboard.SetText RichTextBox1.Text
'Paste Clipboard selection to Rich Text Box 2
RichTextBox2.Text = Clipboard.GetText
End Sub
Private Sub Command3_Click()
' Selects and copies the text from Rich Text Box 3 to the Clipboard
Clipboard.SetText RichTextBox3.Text
'Paste Clipboard selection to Rich Text Box 4
RichTextBox2.Text = Clipboard.GetText
End Sub
Above is the code for the 2 command button with notes.
Thanks
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
|