Newsgroup: it.comp.lang.visual-basic
Titolo: copia e incolla campo di testo ??

ciao a tutti, ho un semplice campo di testo (TextBox) multilinea con barre
di scorrimento verticali. Quello che vorrei č potere, facendo click su un
CommandButton, copiare quanto č scritto nel campo di testo negli appunti di
Windows.
Come posso fare ??
grazie,

 ha scritto

SetText Method
Puts a text string on the Clipboard object using the specified Clipboard
object format. Doesn't supportnamed arguments.
Syntax
object.SetText data, format
The SetText method syntax has these parts:
      Part Description
      object Required. Anobject expression that evaluates to an object in
the Applies To list.
      data Required. String data to be placed onto the Clipboard.
      Format Optional. A constant or value that specifies one of the
Clipboard formats recognized by Visual Basic, as described in Settings.
Settings
The settings for format are:
      Constant Value Description
      vbCFLink &HBF00 DDE conversation information
      vbCFRTF &HBF01 RichText Format
      vbCFText 1 (Default) Text
Remarks
These constants are listed in the Visual Basic (VB)object library in
theObject Browser.
vedi anche gettext:
GetText Method
Returns a text string from the Clipboard object. Doesn't supportnamed
arguments.
Syntax
object.GetText (format)
The GetText method syntax has these parts:
      Part Description
      object Required. Anobject expression that evaluates to an object in
the Applies To list.
      format  Optional. A value or constant that specifies the Clipboard
object format, as described in Settings.  Parentheses must enclose the
constant or value.
Settings
The settings for format are:
      Constant Value Description
      vbCFLink &HBF00 DDE conversation information
      vbCFText 1 (Default) Text
      vbCFRTF &HBF01 Rich Text Format (.rtf file)
Remarks
These constants are listed in the Visual Basic (VB)object library in
theObject Browser.
If no text string on the Clipboard object matches the expected format, a
zero-length string ("") is returned.
esempio msdn:
Private Sub Form_Click ()
   Const CF_TEXT = 1   ' Define bitmap format.
   Dim I, Msg, Temp   ' Declare variables.
   On Error Resume Next   ' Set up error handling.
   Msg = "Type anything you like into the text box below."
   Text1.Text = InputBox(Msg)   ' Get text from user.
   Msg = "Choose OK to copy the contents of the text box "
   Msg = Msg & "to the Clipboard."
   MsgBox Msg   ' Display message.
   ClipBoard.Clear   ' Clear Clipboard.
   Clipboard.SetText Text1.Text   ' Put text on Clipboard.
   If Clipboard.GetFormat(CF_TEXT) Then
      Text1.Text = ""   ' Clear the text box.
      Msg = "The text is now on the Clipboard. Choose OK "
      Msg = Msg & "to copy the text from the Clipboard back "
      Msg = Msg & "to the text box."
      MsgBox Msg   ' Display message.
      Temp = Clipboard.GetText(CF_TEXT)   ' Get Clipboard text.
      For I = Len(Temp) To 1 Step -1   ' Reverse the text.
         Text1.Text = Text1.Text & Mid(Temp, I, 1)
      Next I
   Else
      Msg = "There is no text on the Clipboard."
      MsgBox Msg   ' Display error message.
   End If
End Sub
vedi anche le cugine, setdata / getdata e quella dell'esempio, getformat.
hth, j.

 testo negli appunti di Windows.
Cerca nell'help l'oggetto Clipboard.
--
Faber

 Come posso fare ??
Private Sub Text1_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
Clipboard.Clear
Clipboard.SetText Text1.SelText
End Sub
Ciao