• Welcome to Valhalla Legends Archive.
 

Opening other files

Started by BlazingKnight, November 02, 2003, 11:24 PM

Previous topic - Next topic

BlazingKnight

How do you open another .exe file through a vb program?

Newby

Correct me if I'm wrong.

Shell filename

8)
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

AzN

        On Error GoTo ssfdsfds
       Shell "C:\Program Files\Starcraft\starcraft.exe"
       GoTo theend
ssfdsfds:
       MsgBox "Error on loading file"
theend:

Adron

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.

drivehappy

Wouldn't a Exit Sub/Function be better than another Goto?

Puzzle

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.

drivehappy

#6
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


Grok

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.

Banana fanna fo fanna

*sigh* VB error handling.

Adron

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!

Mesiah / haiseM

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.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

K

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?

Mesiah / haiseM

yes, amungst a few others.
]HighBrow Innovations
Coming soon...

AIM Online Status: