dcsimg
Results 1 to 16 of 16

Thread: [RESOLVED] Clipboard adding to existing text

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    Resolved [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"

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    Re: Clipboard adding to existing text

    Example: Putting clipboard info into a textbox and add text:

    Code:
    text1.text = clipboard.gettext & " Mickey Kelly"

  3. #3
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,393

    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"

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    Re: Clipboard adding to existing text

    It does not like vbCr or vbLf or together.

    Clipboard.SetText Clipboard.GetText() & vbLf & vbCr & "xys"

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    Re: Clipboard adding to existing text

    It does not like vbCr or vbLf or together.

    Clipboard.SetText Clipboard.GetText() & vbLf & vbCr & "xys"

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    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.

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    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

  9. #9
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    Re: Clipboard adding to existing text

    use vbcrlf

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    Re: Clipboard adding to existing text

    like this:

    Code:
    Clipboard.SetText Clipboard.GetText & vbCrLf & vbCrLf & "XYZ"

  11. #11
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    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

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,238

    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

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    Re: Clipboard adding to existing text

    The vbCrLf combined works. Thanks guys.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    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

  15. #15
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,393

    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.

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    149

    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
  •  



Featured


Click Here to Expand Forum to Full Width