...

View Full Version : Visual Basic: Clipboard Methods



mpicklesimer
01-14-2004, 11:46 PM
I have 4 buttons that I need to add code to. They are Cut, Copy, Paste and Delete. I need these buttons to function as expected, but my book never explains anything beyond "Use the Clipboard methods". I'm starting to hate this class. Thanks in Advance.

DsgnrsTLZAdmin
01-15-2004, 12:05 AM
for the cut code:


On Error Resume Next
Clipboard.SetText ActiveForm.rtfText.SelRTF
ActiveForm.rtfText.SelText = vbNullString



for the copy code:


On Error Resume Next
Clipboard.SetText ActiveForm.rtfText.SelRTF



for the paste code:


On Error Resume Next
ActiveForm.rtfText.SelRTF = Clipboard.GetText




and for delete? i dont know what you mean delete.....but cut and delete should be the same


these are on the asumption that these controls will be for a textbox...just change the names to the name for your textbox if thats what its for.

mpicklesimer
01-15-2004, 12:14 AM
You're right. The Delete button and the Cut button would both remove the selected text from the text box, but Delete would do it without saving it to the Clipboard. Yes, my teacher does look at the code to see if I'm cheating. Thank you TLZ

mpicklesimer
01-15-2004, 12:21 AM
I took the code that you gave me and put the following line of code into my program:



ActiveForm.rtfText.SelRTF = ""

So when you click the delete button, it takes the selected text and replaces it with what's between the quotes (absolutely nothing, lol). It's not pretty, I guess, but it certainly gets the job done.

Thank you again.

DsgnrsTLZAdmin
01-15-2004, 07:15 PM
No problem, have fun with your adventures in VB. And what you did for the delete is perfect fine, in my opionin anything that gets the job done is fine even if some people say its sloppy.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum