-
Hey guys,
I am creating an editor of my own for a VB project. I have been able to implement New, Open and Exit commands successfully. But I am stuck with Cut, Copy, Paste and Delete features of the Implementation.
Do you guys have an suggestions on how to implement the cut, copy, paste, and delete actions(Even the logic aspect will be sufficient)? Thank you in advance.
Manoj
-
Hi sweetsupra,
Look into using the Clipboard object. That's where I would start.
All the best.
-
OneSource is correct, the best way to do this is with the Clipboard. Here's the code (unabashedly stolen from a textbook by Diane Zak, "Programming with Microsoft Visual Basic X.0" (X.0 = 4.0, 5.0, 6.0 etc.) - great book for beginners, btw).
The following code assumes that you have a menu item named "mnuEdit" with sub-items named "mnuCopy", "mnuCut", "mnuPaste", and "mnuDelete", and that your textbox is called txtEdit:
Code:
Private Sub mnuEdit_Click()
' enable/disable copy and cut commands, depending
' on whether any text is selected ...
If txtEdit.SelText = "" Then
mnuCut.Enabled = False
mnuCopy.Enabled = False
Else
mnuCut.Enabled = True
mnuCopy.Enabled = True
End If
' enable/disable Paste command, depending on
' whether or not any text is in the Clipboard ...
If Clipboard.GetText() = "" Then
mnuPaste.Enabled = False
Else
mnuPaste.Enabled = True
End If
End Sub
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText txtEdit.SelText
End Sub
Private Sub mnuCut_Click()
Clipboard.Clear
Clipboard.SetText txtEdit.SelText
txtEdit.SelText = ""
End Sub
Private Sub mnuPaste_Click()
txtEdit.SelText Clipboard.GetText()
End Sub
Private Sub mnuDelete_Click()
txtEdit.SelText = ""
End Sub
-
Try the Visual Basic Application Wizard first.I learnt a lot of things from it. File->New Project. then VB Application Wizard.