How do you open another .exe file through a vb program?
Correct me if I'm wrong.
Shell filename
8)
On Error GoTo ssfdsfds
Shell "C:\Program Files\Starcraft\starcraft.exe"
GoTo theend
ssfdsfds:
MsgBox "Error on loading file"
theend:
I recommend you insert a "Resume theend" right before theend:. If you don't finish error processing with a resume, any future error won't be handled right.
Wouldn't a Exit Sub/Function be better than another Goto?
Quote from: drivehappy on January 04, 2004, 11:46 PM
Wouldn't a Exit Sub/Function be better than another Goto?
Not unless that's the end of the sub or function which is most likely not the case.
Well, just put the error label at the end:
Public Sub Blah
On Error GoTo ssfdsfds
Shell "C:\Program Files\Starcraft\starcraft.exe"
MoreCrap()
Exit Sub
ssfdsfds:
MsgBox "Error on loading file"
End Sub
My standard invocation is as follows:
Private Sub WhateverTask()
On Error Goto WhateverTaskErr
'do stuff
WhateverTaskExit:
Exit Sub
WhateverTaskErr:
Dim lErr As Long, sErr As String, lLine As Long
lErr = Err.Number : sErr = Err.Description : lLine = Erl
Resume WhateverTaskExit
End Sub
There's a little more to it than that, depending on what the procedure is doing. I might put a Select..Case in the Error Handler, possibly a MsgBox and offer to Retry, Ignore or Cancel, depending on the error and what is appropriate. If they choose Cancel, you'd resume WhateverTaskExit. If they Retry, you Resume, and if they choose Ignore, you do Resume Next.
What you get tired of write all those error handlers, you'll be practiced enough to start writing general error handlers, which requires a little advance maintenance in each procedure you want to take advantage of it.
*sigh* VB error handling.
Quote from: St0rm.iD on January 10, 2004, 10:30 PM
*sigh* VB error handling.
I've done that too. But vbdump.dll helps a lot!
Are you just trying to open another application, or are you trying to open it as a child, and set your form as the parent? A long time ago, when i first got into programming, I was in open tech support, and skywing told me it was impossible, but it isn't :P
Just wondering, reply if you need code for this technique.
Quote from: MesiaH on January 17, 2004, 01:44 PM
Are you just trying to open another application, or are you trying to open it as a child, and set your form as the parent? A long time ago, when i first got into programming, I was in open tech support, and skywing told me it was impossible, but it isn't :P
Just wondering, reply if you need code for this technique.
You mean using the
SetParent function?
yes, amungst a few others.