Copy, Cut and Paste

  • Thread starter Thread starter Tor Inge Rislaa
  • Start date Start date
T

Tor Inge Rislaa

Copy, Cut and Paste

How to code the Copy, Cut and Paste functionality in VB.NET. In VB 6.0 I
used the following code:


'For Copy

Clipboard.Clear
Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText

'For Cut
Clipboard.Clear
Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText
ActiveForm.ActiveControl.SelText = ""

'For Paste
If Clipboard.GetFormat(vbCFText) Then
ActiveForm.ActiveControl.SelText = Clipboard.GetText(vbCFText)
End If

T.I.Rislaa
 
Hi,

To copy :
Clipboard.SetDataObject(TextBox1.Text)

To paste:
Label1.Text = Clipboard.GetDataObject().GetData(DataFormats.Text)

Let me know if it works.

- Gary -
 
Tor Inge Rislaa said:
Copy, Cut and Paste

How to code the Copy, Cut and Paste functionality in VB.NET. In VB
6.0 I used the following code:


'For Copy

Clipboard.Clear
Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText

'For Cut
Clipboard.Clear
Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText
ActiveForm.ActiveControl.SelText = ""

'For Paste
If Clipboard.GetFormat(vbCFText) Then
ActiveForm.ActiveControl.SelText = Clipboard.GetText(vbCFText)
End If

T.I.Rislaa

VS 2003:

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vbcon/html/vxconChangesToClipboard
ObjectInVisualBasicNET.htm

(see hints in signature)


--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.
 
Back
Top