Underc0de

Programación General => Visual Basic => Códigos Fuentes => Mensaje iniciado por: ANTRAX en Julio 26, 2010, 04:00:13 PM

Título: Copiar, pegar y cortar lo que haya escrito en un Text Box
Publicado por: ANTRAX en Julio 26, 2010, 04:00:13 PM
Para comenzar creamos un nuevo form y le metemos tres Commands Botonns y un Text Box.
Luego le cambiamos el texto a los botones por: Copiar, Pegar y Cortar y en el textbox escribimos cualquier cosa, yo en este caso voy a poner "Esto es un ejemplo de Copiar, Pegar y Cortar"

(http://img236.imageshack.us/img236/6989/pic1mk9.jpg)

Bien, ahora vamos a escribir el código.
En el Command 1(el de Copiar) escribimos esto:

Private Sub Command1_Click()
Clipboard.Clear
Clipboard.SetText Text1.SelText
Text1.SetFocus
End Sub


En Command 2(de Pegar):

Private Sub Command2_Click()
Text1.SelText = Clipboard.GetText()
Text1.SetFocus
End Sub


Y en Command 3(de Cortar):

Private Sub Command3_Click()
Clipboard.SetText Text1.SelText
Text1.SelText = ""
Text1.SetFocus
End Sub


(http://img218.imageshack.us/img218/9895/pic2yn5.jpg)

Manual por: Darkwolf