neutrinohunter
asked on
Copy Text From RichTextBox
I am trying to make a commandbutton (Called Copy) when clicked copy text from a RichTextBox (Called RTB)
But...
A) If no text is selected it selects and copies all the text in the RTB
B) If some text is selected it coped only the selected text.
But...
A) If no text is selected it selects and copies all the text in the RTB
B) If some text is selected it coped only the selected text.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If RTB.SelLength=0 then
'no text is select
YourString=RTB.Text
Else
'nr of char of selected text
YourString=RTB.SelText
End if
Clipboard.Clear
Clipboard.SetText = YourString
' If you accept this, give the points to Djinn_ro
'no text is select
YourString=RTB.Text
Else
'nr of char of selected text
YourString=RTB.SelText
End if
Clipboard.Clear
Clipboard.SetText = YourString
' If you accept this, give the points to Djinn_ro
ASKER
k, but what does YourString mean?
I pasted all that in my code, but it says
Variable Not defined?
I pasted all that in my code, but it says
Variable Not defined?
define the variable...
Dim YourString As String
Dim YourString As String
ASKER
I tried that.
Its says
Compile Error;
Argument not optional
? Help Please.
Its says
Compile Error;
Argument not optional
? Help Please.
what argument? what line?
ASKER
This line
Clipboard.SetText = YourString
Clipboard.SetText = YourString
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There's two choices... one that copies text and one that copies rtf text
ASKER
What I meant was I am trying to copy the text from a RichTextBox
But the code I am using seems to work only for textboxes. Thus it aint copying any text.
So if someone could post a code to Copy the text aswell as select the text as Djinn_ro posted that would be gr8
Thx