Results 1 to 4 of 4

Thread: Error Handling when calling a DLL

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    51

    Post

    Hi. I'm writing a program that calls a procedure that is in a DLL. When the procedure fails, I have error handling to exit the program. The problem is that when the program exits, the entire VB design environment exits also. This only happens to me when I get an error using a DLL. Does anyone know how to prevent the VB design environment from exiting also? Thanks!

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Posts
    82
    hi,
    can you write down the error handler so i can maybe see what you wrote and maybe something is wrong. if you just wrote "End" then i haven't a clue.

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    51
    On Error GoTo safe

    safe:
    MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
    Err.Clear
    Set session = Nothing 'gets rid of object that uses dll
    Exit Sub

    The "on error" statement is of course at the beginning of the sub while everything past the "safe:" anchor is at the end. Everything seems to work fine except when I hit the terminate button on the application or the stop button in the vb design environment, my program quits but unfortunately the entire vb design environment quits with it. It's frustating because I have to keep going back into it.

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    51
    actually, here, I'll give you the entire program:

    Option Explicit

    Dim session As Object
    Dim folder As Object
    Dim msgs As Object
    Dim mess As Object

    Private Sub Form_Load()

    On Error GoTo safe

    Set session = CreateObject("CTI.Session.1")
    session.CTLogon "WM2", "jrumajas", "mandrake"

    Set folder = session.Inbox
    Set msgs = folder.Messages
    Set mess = msgs.GetFirst

    MsgBox mess.Text
    MsgBox "the length of body is: " & Len(mess.Text)
    Set mess = Nothing

    Set mess = session.Inbox.Messages.GetNext
    MsgBox mess.Text
    MsgBox "the length of body is: " & Len(mess.Text)

    Set mess = Nothing
    Set msgs = Nothing
    Set folder = Nothing
    session.Logoff

    MsgBox "Done "
    session = Nothing

    safe:
    MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
    Err.Clear ' Clear the error.
    'Resume Next
    Set session = Nothing
    'End
    Exit Sub
    End Sub

    The error says:
    Error #-2147221227 Method 'CTLogon' of object 'ISession' failed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width