Results 1 to 5 of 5

Thread: A question in clipboard!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    120

    A question in clipboard!

    Hi...
    I have a textbox and a command button..
    and i want to paste the text from the clipboard to the text So:

    Command1_click:
    text1.seltext=clipboard.gettext
    End sub

    So when i click on the command button the content of the clipboard will paste into the text box
    but here is the problem...I only want it to paste 1 time..you see if i exemple copy the word "HHHH" when i click on the command1 it will paste it over and over like that "HHHHHHHHHHHHHHHHHHHHHHHHHHH" but i just want it to paste it one time "HHHH" even if i kepp clicking on the command button..
    ....................................................................................................
    I'm sure that you didn't understand a word cause i'm not that good with english

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: A question in clipboard!

    Then, right after the paste, do a Clipboard.Clear

    That will clear everything currently stored in the clipboard.

    If you don't want to do that, then you can encapsulate your paste code within an If statement to see if there is anything in the textbox already. If there is, then don't do the paste; if it is empty, do the paste.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: A question in clipboard!

    Either clear the clipboard after you've pasted the text or have a check if the current clipboard text already have been pasted.
    VB Code:
    1. Private Sub Command1_Click()
    2.     Text1.SelText = Clipboard.GetText(vbCFText)
    3.     Clipboard.Clear
    4. End Sub

    VB Code:
    1. Private Sub Command1_Click()
    2.     Static sLastText As String
    3.     Dim sTxt As String
    4.  
    5.     sTxt = Clipboard.GetText(vbCFText)
    6.     If sTxt <> sLastText Then
    7.         Text1.SelText = sTxt
    8.         sLastText = sTxt
    9.     End If
    10. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    120

    Re: A question in clipboard!

    Quote Originally Posted by Hack
    Then, right after the paste, do a Clipboard.Clear

    That will clear everything currently stored in the clipboard.

    If you don't want to do that, then you can encapsulate your paste code within an If statement to see if there is anything in the textbox already. If there is, then don't do the paste; if it is empty, do the paste.
    First...Thx for your help
    But if i use the if statement to see if there is anything in the textbox already..
    and if there is i don't do the paste and if there is do the paste..
    but what if i paste something in the text and then i copy something else!!!!!
    that way the text is not empty so it won't do the paste

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: A question in clipboard!

    Quote Originally Posted by Shady Soft
    First...Thx for your help
    But if i use the if statement to see if there is anything in the textbox already..
    and if there is i don't do the paste and if there is do the paste..
    but what if i paste something in the text and then i copy something else!!!!!
    that way the text is not empty so it won't do the paste
    Ok, then if I'm reading you correctly, once you have it pasted in, you don't need it anymore, so just do the Clipboard.Clear and forget about the textbox check.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width