CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: One more Bug!!!

  1. #1
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    One more Bug!!!

    I have created a program which searches a database with some criteria and it displays the results in a data report. The problem is that although the .exe works well, the vb project crashes at the first(!) run on Kernel32.dll. So I can make any changes on the project because I cannot run it. I must compile it everytime and test the .exe. I think it's crazy!!! I tried to copy the code to another project, but with same results. By the way, I use VB6 with SP3.
    All good ideas will be rated...

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    same old bug? :-)

    I'd try these approaches:
    - try the same thing on another machine.
    - search MSDN to see if there are any reported bugs with the Data report. I didn't find any!
    - post the complete (!) code. Somebody might have time to try to reproduce that behavior.
    - uninstall VB and install from scratch.
    - reinstall Windows (and VB)


  3. #3
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Yeah! You have a really good memory! :-)))

    REinstall windows is something difficult (timeless). Reinstalling vb is something I'll try soon. You asked about the whole code. It's very difficult because it comes accross with the database etc. Anyway, thanx for your try, I'll keep trying searching about new bugs. :-D


    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: One more Bug!!!

    Hi

    I've seen this kind of problem before - When I 'discovered' it in a large project, we were doing something similar to the following :

    1. Create Object A locally
    2. Create Object B from DLL
    3. Pass Object A into Object B
    4. Do some work with Object B (which works with Object A)
    4. Set Object B = nothing

    Now this worked fine in debug mode, but as soon as the program was run as an EXE we had all kinds of weird errors. The problem was that the DLL object B still had a reference to an Object in the EXE even though the reference to B had been cleared down.

    This kind of circular reference can cause lot's of different GPF's and can be a nightmare to track down.

    This might not be the cause of your problem, but I thought it might be interesting.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  5. #5
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    I think I found it!

    Well, I found an error on my own code, and when I corrected it, it didn't crash again:
    Wrong code:

    If frmMain.blnNumberSearch = true then
    dePrinting.rsPrintFields.Filter = " P_FLD0 = " & CStr(frmMain.intP_FLD0) & " AND P_FLD5 <= " & CStr(frmMain.lngNumberTo) & " AND P_FLD5 >= " & CStr(frmMain.lngNumberFrom) & ""
    end if



    Correct code:

    If frmMain.blnNumberSearch = true then
    dePrinting.rsPrintFields.Filter = " P_FLD0 = " & CStr(frmMain.intP_FLD0) & " AND P_FLD5 <= " & CStr(frmMain.lngNumberTo) & " AND P_FLD5 >= " & CStr(frmMain.lngNumberFrom) & "'"
    end if



    But is this a reason for vb to crash in kernel32.dll? And if we suppose that it corrected the crash, another problem exists yet:
    On first run the report is blank and on second it is correct. However, the exe still works well!!!


    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  6. #6
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Unfortunately it is not my bug!

    It crashed again after the correction I made, so it is definetely a bug of reports. :'-(

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  7. #7
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Final Solution:

    Well, here is the bug:
    Wrong code:

    private Sub DataReport_Terminate()
    End
    End Sub



    Correct code:

    private Sub DataReport_QueryClose(Cancel as Integer, CloseMode as Integer)
    End
    End Sub




    Question:
    Is it my fault or VB's ???

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  8. #8
    Join Date
    May 1999
    Posts
    3,332

    Re: Final Solution:

    IMHO the IDE should never crash, no matter what you do. I'd accepts crashes whenever you pass addresses to SDK functions (as in subclassing), but not with regular VB syntax.

    OTOH, I would never End my program when a report ends or a report window is terminated. But that's a different story.


  9. #9
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Final Solution:

    I'd say it's your bug - the 'End' statement will terminate the program there and then.

    If you think about it, this is what's happening from the DataReports point of view :

    1. Do some processing
    2. Tell the container that we're finished
    3. Do some final checking/cleaning up (usercontrol_terminate etc)

    Meanwhile, VB is expecting to issue a 'Terminate' event to kill off the control when it's no longer used. Of course it can't because you've effectively killed the program without it being able to tidy up it's own memory / address spaces.

    Memory leaks anyone ?

    I think the moral here is (and haven't we been down this route before?), never use the END statement in your programs. Make sure all your forms and objects are unloaded and your program will end gracefully.



    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  10. #10
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    OK, Thanx but...

    ... why on the first run the report is blank?
    I have only labels and text boxes on the report. What do you suggest to do when I want to close the program?


    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  11. #11
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Your solution?

    I want my program to terminate when the report is closed. How else can I manage it?

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  12. #12
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: OK, Thanx but...

    >... why on the first run the report is blank?

    I don't know about that ....

    >What do you suggest to do when I want to close the program?

    If you only have the one form and that's setup as the start-up object, why not have a simple 'Unload Me' command in the 'DataReport_QueryClose' or 'DataReport_Terminate' events ?




    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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

Featured