help required for: Copy / Paste command

  • Thread starter Thread starter Max81
  • Start date Start date
M

Max81

Im trying to build a calculator for an assignment! (due wednesday)

im having trouble finding any code for creating Copy/Paste menu
buttons (just need the "doing" code)

can anyone help?

in addition, how do you get the keyboard numbers to activate the
"calculator" buttons. (not as important)

thanks for any info provided.

Max

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Max,
This is my routine, which I got from this group many Moons ago:

' =====================================================

Function CutCopyPaste(ByVal type As Integer, ByVal ctrl As Control) As
String

'Type is 1=Cut 2=Copy 3=Paste

'ctrl is control being cut or copied from or if type=3 is the control being
pasted to.

Select Case type

Case 1 '=Cut

Try

Clipboard.SetDataObject(ctrl.Text)

ctrl.Text = "" 'THEN clear the source control

Catch ex As Exception

Call ProgErrorHandler("CutCopyPaste - Cut", "Common Module", ex.Message,
False)

End Try

Case 2 '=Copy

Try

Clipboard.SetDataObject(ctrl.Text)

Catch ex As Exception

Call ProgErrorHandler("CutCopyPaste - Copy", "Common Module", ex.Message,
False)

End Try

Case 3 '=Paste

Try

Catch ex As Exception

Dim objClipboard As IDataObject = Clipboard.GetDataObject()

With objClipboard

If .GetDataPresent(DataFormats.Text) Then

ctrl.Text = .GetData(DataFormats.Text)

End If

End With

End Try

End Select

End Function

' =====================================================
 
Max,

Please note that the call to ProgErrorhandler is just a generic routine that
I use to display a message about the error that occurs:
Public Sub ProgErrorHandler(ByVal FuncOrSubName As String, ByVal FormName As
String, ByVal ErrMessage As String, Optional ByVal CloseApplication As
Boolean = False)

'This is the routine that is passed error details for display to the
user and which will shut down the application if the error is sufficiently

'Serious as denoted by the "CloseApplication" parameter, can be left and
False assumed

Dim Msg As String

Msg = "An error has occurred in the " & FuncOrSubName & " procedure in
the " & FormName & " form." & vbCrLf & vbCrLf

Msg += "The error message returned is:" & vbCrLf & vbCrLf & ErrMessage &
vbCrLf & vbCrLf

Select Case CloseApplication

Case False

Msg += "This error is not too serious to continue, but the
information from this dialog should be reported to " & Support

Msg += ". If this error occurred whilst making changes to the
database, it is likely that your data has not been saved. "

Case True

Msg += "This error is too serious to continue running the
application, any outstanding changes will be lost. Please make a note "

Msg += "of the message details above and pass them to " & Support &
" so that the cause of this error can be rectified in a "

Msg += "future release of this application. I apologise for this
problem and will endeavour to fix it as soon as possible "

Msg += "once I know where the error lies."

MsgBox(Msg, MsgBoxStyle.Information, H)

Call EndApplication()

End Select

Dim Resp As Integer = MsgBox(Msg, MsgBoxStyle.Information, H)

End Sub

The variable "Support" just holds the relevant support desk name and number.
The EndApplication routine is just used to close down any global variables
and shut down forms etc

Hope they are useful.

Siv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top