-
Oct 2nd, 2019, 03:04 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Clipboard adding to existing text
I can't seem to add text to what is already in the clipboard. Is there a way to cosntantanant text. For example adding to the beginning or ending of it? I have tried this but it does not seem to work:
Clipboard.SetText Clipboard.GetText() & Chr$(13) & Chr$(13) & "XYZ"
-
Oct 2nd, 2019, 03:09 PM
#2
Re: Clipboard adding to existing text
Example: Putting clipboard info into a textbox and add text:
Code:
text1.text = clipboard.gettext & " Mickey Kelly"
-
Oct 2nd, 2019, 03:16 PM
#3
Re: Clipboard adding to existing text
Try this:
Code:
Dim l_Clip As String
l_Clip = Clipboard.GetText
Clipboard.Clear ' Clear before setting clipboard text
Clipboard.SetText l_Clip & Chr$(13) & Chr$(13) & "XYZ"
-
Oct 2nd, 2019, 03:28 PM
#4
Thread Starter
Addicted Member
Re: Clipboard adding to existing text
Actually my original code was working EXCEPT for the attempt at carriage return to get the spacing. I just didn't pay attention that it had added the XYZ but did not put the line feeds. Now to figure out the line feeds.
-
Oct 2nd, 2019, 03:29 PM
#5
Thread Starter
Addicted Member
Re: Clipboard adding to existing text
It does not like vbCr or vbLf or together.
Clipboard.SetText Clipboard.GetText() & vbLf & vbCr & "xys"
-
Oct 2nd, 2019, 03:30 PM
#6
Thread Starter
Addicted Member
Re: Clipboard adding to existing text
It does not like vbCr or vbLf or together.
Clipboard.SetText Clipboard.GetText() & vbLf & vbCr & "xys"
-
Oct 2nd, 2019, 03:33 PM
#7
Re: Clipboard adding to existing text
Are you trying to put the CRLF INTO the clipboard, or simply ADD them afterwards, like:
Code:
Private Sub Command1_Click() 'put something INTO the clipboard
Clipboard.SetText (Text2.Text)
End Sub
Private Sub Command2_Click() 'get what is in the clipboard and put it somewhere (like a Multi-Line text box (Text1))
Text1.Text = Clipboard.GetText & vbCrLf & vbCrLf & "XYZ"
End Sub
Last edited by SamOscarBrown; Oct 2nd, 2019 at 03:37 PM.
-
Oct 2nd, 2019, 03:36 PM
#8
Re: Clipboard adding to existing text
If attempting to put CR+LF INTO clipboard, do this:
Code:
Private Sub Command1_Click() 'put text plus 2 CRLF's and some text into clipboard
Clipboard.SetText (Text2.Text) & vbCrLf & vbCrLf & "XYZ"
End Sub
Private Sub Command2_Click() 'get it back out
Text1.Text = Clipboard.GetText
End Sub
-
Oct 2nd, 2019, 03:37 PM
#9
Re: Clipboard adding to existing text
-
Oct 2nd, 2019, 03:41 PM
#10
Re: Clipboard adding to existing text
like this:
Code:
Clipboard.SetText Clipboard.GetText & vbCrLf & vbCrLf & "XYZ"
-
Oct 2nd, 2019, 03:44 PM
#11
Re: Clipboard adding to existing text
test it by putting something into the clipboard:
Code:
Private Sub Command1_Click()
Clipboard.SetText "HELLO"
End Sub
Then:
Code:
Private Sub Command2_Click()
Clipboard.SetText (Clipboard.GetText & vbCrLf & vbCrLf & "XYZ")
End Sub
Then:
Code:
Private Sub Command3_Click()
Text1.Text = Clipboard.GetText
End Sub
-
Oct 2nd, 2019, 03:54 PM
#12
Re: Clipboard adding to existing text
Just playing around:
Code:
Private Sub Command1_Click()
Clipboard.SetText "THIS IS THE ORIGINAL TEXT IN THE CLIPBOARD!"
End Sub
Private Sub Command2_Click()
Clipboard.SetText ("Thia ia text added before what is on the clipboard." & vbCrLf & Clipboard.GetText & vbCrLf & "And This is text added at the end,")
End Sub
Private Sub Command3_Click()
Text1.Text = Clipboard.GetText
End Sub
-
Oct 2nd, 2019, 04:22 PM
#13
Thread Starter
Addicted Member
Re: Clipboard adding to existing text
The vbCrLf combined works. Thanks guys.
-
Oct 2nd, 2019, 04:45 PM
#14
Thread Starter
Addicted Member
Re: Clipboard adding to existing text
I am so old school from the DOS days that my initial brain works on the CHR$(13) mode and that does not always work, but usually. So then I remembered to do the carriage return and line feed so the vbCr & vbLf. I guess I don't think in one variable being the solution but I need to retrain my old brain. Thanks
-
Oct 2nd, 2019, 04:48 PM
#15
Re: [RESOLVED] Clipboard adding to existing text
The problem is that in the first example you were just doing CR twice, not CRLF and in the second example you were doing LFCR instead of CRLF. If you had done : Chr$(13) & Chr$(10) then you would have been OK, although using vbCrLf or even vbNewLine is the better choice.
-
Oct 2nd, 2019, 09:37 PM
#16
Thread Starter
Addicted Member
Re: [RESOLVED] Clipboard adding to existing text
Not aware of vbNewLine. Thanks. Learned some more new. You can teach an old dog new tricks.
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
|