|
-
Nov 9th, 2000, 07:54 AM
#1
Thread Starter
New Member
I Have been trying for ages to get a copy and paste function to work in my application, but I just cant figure out how to do it! All I want to do is highlight something in one of my text boxes, go to the edit menu, click on copy and then paste the data into a new text box using the edit menu, but its proving very annoying and difficult. Can any of you help me??
-
Nov 9th, 2000, 08:36 AM
#2
Fanatic Member
Hi. I experimented with this for a few minutes and the following will allow you to copy text from one textbox to the clipboard and then paste that text into another textbox. The Clipboard object is shared by all Windows applications, so no need to declare it in VB.
Code:
Option Explicit
Private Sub CmdCopy_Click()
Clipboard.Clear
Clipboard.SetText (Text1.SelText)
End Sub
Private Sub CmdPaste_Click()
Text2 = Clipboard.GetText
End Sub
Maybe it will give you a starting point to work from.
-
Nov 9th, 2000, 10:04 AM
#3
_______
<?>
'From textbox to textbox you don't need copy 'n' paste
Code:
Private Sub Command1_Click()
'paste it at the end of text2.text
'could be anywhere you want or overwrite
Text2.SelStart = Len(Text2.Text)
Text2.Text = Text2.Text & " " & Text1.SelText
End Sub
Private Sub Form_Load()
Text1.Text = "Mary Lou"
Text2.Text = "Hello"
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 9th, 2000, 10:26 AM
#4
New Member
Try This
Put a menu up (Edit) subitems Copy, Paste
Place two textboxes on form
Private Sub mCopy_Click()
If Me.ActiveControl.Name Like "Text*" Then
Clipboard.Clear
Clipboard.SetText Me.ActiveControl.Text
End If
End Sub
Private Sub mPaste_Click()
If Me.ActiveControl.Name Like "Text*" Then
Me.ActiveControl.Text = Clipboard.GetText
End If
End Sub
-
Nov 9th, 2000, 10:53 AM
#5
You should check to see if text is highlighted as well.
Code:
Private Sub CmdCopy_Click()
If Text1.SelText <> "" Then
Clipboard.Clear
Clipboard.SetText (Text1.SelText)
End If
End Sub
But as Wayne (HeSaidJoe) said, you don't need copy and paste to put something from one textbox to the other.
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
|