INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Crashing MC  (Read 1198 times)

nila

  • Guest
Crashing MC
« on: January 23, 2004, 05:50:31 am »

Hi Guys,
Was just wondering if anyone could see or tell me why this code would be causing MC to close instantly when it is compiled:

Public g_MC As MediaJukebox.MJAutomation

Public Sub Main()

    On Error GoTo anError
    ' First try to get an already running object
    Set g_MC = GetObject(, "MediaJukebox Application")

anError:
    If Err.Number = 429 Then
        'Then, create a new object
        Set g_MC = CreateObject("MediaJukebox Application")
    End If

    MsgBox Command$


End Sub


As soon as I call the program it kills MC instantly and as you can see it's v. basic. Was just wondering if I'm doing something wrong or if I have to close or drop the MC object or anything before the program ends?
Any help appreciated, thanks!
Logged

nila

  • Guest
Re:Crashing MC
« Reply #1 on: January 23, 2004, 06:06:04 am »

Just thought I'd add - it's in VB6 and I'm using it in sub main() rather than form load so that it can be called from the command line easily without any form appearing.

If I put it in the form load event then MC doesn't close when the program opens, but closes as soon as I close the form for the program.

Any way to stop this happening?
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
Re:Crashing MC
« Reply #2 on: January 23, 2004, 06:29:57 am »

Don't know what is causing your problem dude but watch out for the infinite loop.

The CreateObject call could fail but since you've got an On Error Goto it will retry the call.   Which will fail, throw an exception and then retry the call, etc, etc.


From my experience only use On Error Goto to jump to the end of the function to tidy up.   Use On Error Resume Next and check for specific errors in most cases.


If you still haven't fixed the issue by the time I get home (4pm) then I'll look at it for you.   Can't do it here as we don't have VB.
Logged
Pages: [1]   Go Up