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
Printable View
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
'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.
that worked but I can't get it to goto like email programs
haven't played with email programs.
You can use
Code:SendMessage Text1.hwnd, WM_CUT, True, 0&
it says that send message is not defined
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
that still doesn't work for me
dimava, take a look at this thread.
I did, and that thing didn't work
HeSaidJoe's code works like a charm!
I have MS Outlook Express And MS Outlook, I can paste into Both of them.....Code:Private Sub Command1_Click()
Clipboard.Clear
Clipboard.SetText Text1.SelText
End Sub
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
ext1
hmmmm works for me,
I selected "ext1" from a text box in VB, and I just pasted, it works....
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?
Code:Private Sub Command1_Click()
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
Clipboard.Clear
Clipboard.SetText Text1.SelText
End Sub
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
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)
you don't actually have to select it, to copy it:
This sends the entire contents of text1 to the clipboardCode:Clipboard.Clear
Clipboard.SetText Text1
da_silvy, as Megatron says, it's slower. Look at this thread.
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.
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.
My way's shorter though.Code:Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Clipboard.SetText Text1.SelText
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.
Which is the same way as your code. And Megatron says that it's slow. Understand?Code:Clipboard.SetText Text1.text
not really, but i don't care
don't worry!
Yeah, maybe Megatron's wrong ;).
Oh well, as long as it works, it's good.
This thread is settled.
thanks to everyone and...
da_silvy
if you were refering to me as he/she, I'm male
ok, i'll remember that