473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

help required for: Copy / Paste command

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
*-----------------------*
Nov 21 '05 #1
2 1540
Siv
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

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

"Max81" <ma******@yamo.org-dot-uk.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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
*-----------------------*

Nov 21 '05 #2
Siv
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

"Siv" <ms**********@removeme.sivill.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
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

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

"Max81" <ma******@yamo.org-dot-uk.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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
*-----------------------*


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
5
by: Tank | last post by:
I have had this post up here when i was trying to figure out how to make leading zeros and have been able to fudge that to work. I am now have trouble getting the loop that makes the folders to...
3
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock...
38
by: Red Dragon | last post by:
I am self study C student. I got stuck in the program below on quadratic equation and will be most grateful if someone could help me to unravel the mystery. Why does the computer refuse to execute...
5
by: roopeman | last post by:
i wrote the below code , just want got local machine application Eventlog 's message , and write to MDB.but it 's can not write the message to Mdb, somebody can check it for me? thanks! ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
2
by: nelsonbrodyk | last post by:
Hey All, I am trying to implement buttons that follow the command pattern. .NET exposes ApplicationCommands.Cut, copy and paste. I am trying the following: <Button...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.