Results 1 to 3 of 3

Thread: VB 5 Keeps crashing on me!

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    51

    Unhappy

    Hello. I'm using vb5 professional edition and whenever my program terminates, the entire vb design environment terminates with it! No errors are being generated within my program. It's is accessing a DLL. Here is the code:

    Option Explicit

    Dim session As Object

    Private Sub cmdLogon_Click()

    On Error GoTo logon_error
    If txtServer.Text = "" Or txtUser.Text = "" Or txtPass.Text = "" Then
    MsgBox "Please input server, user and password."
    Else
    session.CTLogon txtServer.Text, txtUser.Text, txtPass.Text
    End If

    Exit Sub
    logon_error:
    MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
    Err.Clear
    Exit Sub
    End Sub

    Private Sub Form_Load()
    Set session = CreateObject("CTI.Session.1")
    End Sub

    Private Sub form_terminate()
    Set session = Nothing
    End Sub

  2. #2
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89
    I don't know about VB5, but I've found that in VB6, inside the Terminate event, the form has already been destroyed, along with the object representing it.

    Private Sub form_terminate()
    Set session = Nothing
    End Sub

    Therefore, when your form_terminate() is called, there is no form anymore. At this point, 'session' is not accessible. In VB6, as soon as you refer to Session, a new copy of the form is automatically created and its Session variable is set to Nothing. My guess is that in VB5, the new form is NOT created and the Session reference therefore crashes VB.

    Solution: Never use Form_Terminate(). Do all your unload processing in Form_Unload.
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    51
    That didn't solve my problem. Even if I set session = nothing before the form unloads, all of vb blows up.

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