copy message box text

kendals

New member
Joined
Oct 31, 2007
Messages
1
Programming Experience
1-3
hi, i have various programs on my computer coded in VB.
When they give error messages i would like to run a program that would copy the error in to the clipboard. I have tried control and c and it does not work all the time. How can i do this?
 
Hello,

I believe you are using VB.Net and not VB. In VB.Net, to copy the error
message to the clipboard, you would have to use the Try, Catch statement.
Then use the Clipboard class object to copy the error message to the clipboard.

You may try the following steps.

Try

code statements.....................

Catch ex As Exception

Clipboard.Clear()
Clipboard.SetData(System.Windows.Forms.DataFormats.Text, ex.Message)
MsgBox("data copied to clipboard")

End Try

I hope this will help.

Regards,
Allen

Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
 
You don't really need a program to do that. When a message box is displayed you can simply press Ctrl+C and it contents will be copied to the clipboard.

To create a program to do it would be messy, because you'd either have to send a Ctrl+C key press into the ether after having ensured that the message box has focus, or else use the Windows API to get the handle of that window specifically, for which you'd need to know the title.
 
Back
Top