Subroutine running when not asked to.

ss002d6252

New member
Joined
Jul 3, 2006
Messages
4
Programming Experience
Beginner
I have a calculator like program which has a function to export a string ('StringBuild') to notepad .

The process start OK but it has a funny problem. When I run Process.Start it also keept running a sub that I had linked to one of the calculator buttons.

I played around with the code but now it runs a hyperlink that I have on the calculator.

Can anyone suggest a way to stop this happening ?. I even tried adding an empty, hidden, button as the last item on the tabindex to see if that would work but it hasn't.

VB.NET:
Process.Start("Notepad.exe")

SendKeys.Send(StringBuild.ToString)
 
You are presumably trying to send text to the Notepad application but that code isn't going to do it. It takes time for Notepad to open and you are calling SendKeys.Send long before that happens. As such, you're sending keys to the wrong app. Presumably you're sending the key strokes to your own app as it won;t have lost focus, so you're activating a button or whatever with the text you're sending.

Basically, don;t use SendKeys if you can avoid it. Why not just save a text file and then open that in Notepad?
 
Back
Top