Results 1 to 25 of 25

Thread: Copy a text box then make it pasteable

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I need to copy the whole text box and then make it pasteble in VB or an email, or what ever. I tried this:

    Clipboard.SetText Text2.SelText

    but it doesn't work
    NXSupport - Your one-stop source for computer help

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'copy and paste text1 to text 2
    '
    Code:
     On Error Resume Next   ' Set up error handling.
      
       Clipboard.Clear   ' Clear Clipboard.
       Clipboard.SetText Text1.Text  ' Put text on Clipboard.
    
      Text2.Text = Clipboard.GetText(vbCFText)   ' Get Clipboard text.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    that worked but I can't get it to goto like email programs
    NXSupport - Your one-stop source for computer help

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    haven't played with email programs.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    You can use

    Code:
    SendMessage Text1.hwnd, WM_CUT, True, 0&
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    it says that send message is not defined
    NXSupport - Your one-stop source for computer help

  7. #7
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Well declare it first in a module
    Copy this or use the api viewer
    This should be written in one row
    Code:
    Public Declare Function SendMessage Lib "user32"
    Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    that still doesn't work for me
    NXSupport - Your one-stop source for computer help

  9. #9
    Guest
    dimava, take a look at this thread.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I did, and that thing didn't work
    NXSupport - Your one-stop source for computer help

  11. #11
    Guest
    HeSaidJoe's code works like a charm!
    Code:
    Private Sub Command1_Click()
        Clipboard.Clear
        Clipboard.SetText Text1.SelText
    End Sub
    I have MS Outlook Express And MS Outlook, I can paste into Both of them.....

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I tried putting it into aol mail, it doesn't work, I tried putting it into vb it didn't work, I even Tried putting it in this vb forum and it still didn't work
    NXSupport - Your one-stop source for computer help

  13. #13
    Guest
    ext1

    hmmmm works for me,
    I selected "ext1" from a text box in VB, and I just pasted, it works....



  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok, I see my mistake, you hae just pointed it out to me. I need to select it first then click copy... but how do I get my program to select the whole text?
    NXSupport - Your one-stop source for computer help

  15. #15
    Guest
    Code:
    Private Sub Command1_Click()
        Text1.SetFocus
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1)
        Clipboard.Clear
        Clipboard.SetText Text1.SelText
    End Sub

  16. #16
    Guest
    Actually, almost same code that Dennis gave was in that thread I gave dimava.

    Code:
    Clipboard.Clear
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Clipboard.SetText Text1.SelText

  17. #17

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    THANKS FOR EVERYONE WHO STAYED WITH ME UNTIL I GOT MY PROBLEM. Sometimes there are things right in front of you and you dont see them (no, I dont ware glasses)
    NXSupport - Your one-stop source for computer help

  18. #18
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    you don't actually have to select it, to copy it:
    Code:
    Clipboard.Clear
    Clipboard.SetText Text1
    This sends the entire contents of text1 to the clipboard

  19. #19
    Guest
    da_silvy, as Megatron says, it's slower. Look at this thread.

  20. #20
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    no, he wasn't

    if you read it carefully, Megatron was saying that selecting all the text, then copying it was twice as slow, and he was suggesting that his method (like mine) was faster

    also, Dimava was not suggesting that he/she was using it as a menu control for Copy.

  21. #21
    Guest
    No, I'll show you:



    Matthew Gates
    Fanatic Member

    Registered: Apr 2000
    Posts: 1537

    Code:
    Clipboard.SetText Text1.text
    __________________
    Matthew Gates
    Email: [email protected]
    ICQ: 73685536
    Visual Basic 4.0 Professional Edition
    Visual Basic 6.0 SP4 Professional Edition


    Megatron
    Guru

    Registered: Mar 1999
    Posts: 3203
    Most programs allow you to copy the selected the Text. for this reason, you should use SelText instead.


    Code:
    Clipboard.SetText Text1.SelText
    __________________
    Megatron
    [email protected]
    Visual Basic 5 SP3
    See the VBFE Library


    Matthew Gates
    Fanatic Member

    Registered: Apr 2000
    Posts: 1537
    Megatron, Crazy VIII said he wanted to copy a textbox to the clipboard, not the selected text.
    __________________
    Matthew Gates
    Email: [email protected]
    ICQ: 73685536
    Visual Basic 4.0 Professional Edition
    Visual Basic 6.0 SP4 Professional Edition

    Megatron
    Guru

    Registered: Mar 1999
    Posts: 3203
    Using SelText will copy the seleted text (if any), however, if no text is selected, then this will copy the whole text.


    Code:
    If Text1.SelText = "" Then
         Clipboard.SetText Text1
    Else
        Clipboard.SetText Text1.SelText
    End If

    [Edited by Megatron on 09-09-2000 at 01:18 PM]
    __________________
    Megatron
    [email protected]
    Visual Basic 5 SP3
    See the VBFE Library


    Matthew Gates
    Fanatic Member

    Registered: Apr 2000
    Posts: 1537
    I know that. But he wants the whole textbox copied.

    Have it your way.

    Code:
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Clipboard.SetText Text1.SelText
    My way's shorter though.



    Megatron
    Guru

    Registered: Mar 1999
    Posts: 3203
    But almost twice as slow.
    __________________
    Megatron
    [email protected]
    Visual Basic 5 SP3
    See the VBFE Library


    The bold line, "My way's shorter though." is referring to the very top post.

    Code:
    Clipboard.SetText Text1.text
    Which is the same way as your code. And Megatron says that it's slow. Understand?







  22. #22
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Red face

    not really, but i don't care

    don't worry!

  23. #23
    Guest
    Yeah, maybe Megatron's wrong .

    Oh well, as long as it works, it's good.

    This thread is settled.

  24. #24

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks to everyone and...


    da_silvy

    if you were refering to me as he/she, I'm male
    NXSupport - Your one-stop source for computer help

  25. #25
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    ok, i'll remember that

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