CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2012
    Posts
    4

    VB6 Program on Win7 32bit machine Run time error msg 0


    Hello,
    I am getting error msg of 0 (err.number) when i run my VB6 program on WIN 7 (32bit) machine. The line that generates the error is frmMain.Show
    Any suggestions in troubleshooting and fixing this issue?
    The program is run as Administrator
    Regards

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    As pointed out on the other forum Err.Number 0 means that there is no error. If you are seeing this it is due to a mistake in your code, either you are using On Error Resume Next then checking the err.number after a line has executed without error or you are using a On Error Goto and do not have an Exit Sub above your error handler causing it to report error 0.

    Show the routine where the error resides if you need more help
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Sep 2012
    Posts
    4

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    Here is the code that gives that error

    [Code]
    Private Sub cmdLogin_Click()
    'Variable declaration


    On Error GoTo Login_Err

    'code for login verification
    'frmMain.show after successfull login
    'having exit sub below does not matter because the error still exists
    'Exit sub

    Login_Exit:
    On Error Resume Next
    Exit Sub
    Login_Err:
    MsgBox Errors.Count

    For Each MyError In DBEngine.Errors
    With MyError
    MsgBox .Number & " " & .Description & " " & .Source
    End With
    Next MyError

    Resume Login_Exit

    End Sub

    [\code]

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    So an error occurs during frmmain.show which throws it to the error trap where you are checking DBEngine.Errors and getting 0 but the actual error would be held in Err.Number Err.Description

    I am not sure what DBEngine is in this context but I would think that would only apply to errors within the DBEngine and not to VB errors.

    Add code to check for VB errors, you could also set your IDE to break on all errors which would cause the IDE to throw the proper message and show the line where the error occurs.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Sep 2012
    Posts
    4

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    This error happens only on WIN 7 32 bit machine, after creating an exe and running it.
    What do you mean by adding code to check for VB Errors. I added line after each code line and determined that the error is happening at frmMain.show line.

    Really appreciate your guidance.

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    Well when a runtime error occurs it is held in the VB Err object if you check Err.Number then anything other than 0 indicates a problem. I have no idea what your DBEngine.Errors would be but I would think it safe to say that would have nothing to do with non database related errors such as file not found and other such things that may occur.

    If the error occurs on frmmain.show then that would indicate that the error may be in the frmmain_load event or frmMain_resize or other such event that may fire when the form is loaded.

    as for discovering what the error is there are a few ways you could do it.

    1: Set the IDE break on all errors which will cause it to ignore your error handlers and break with an error message when an error occurs this shows you what the error is and where it occurs, though in the case of form.show the cause of the error is usually somewhere within that forms code.

    2: In your error handler check the Err.Number if it is anything other than 0 then an error has occured and you can get the message by displaying err.description

    3: You can use in line error handling by adding an On Error Resume Next before the troublesome line then after the line check the err.number and display if not = 0

    what code is in the load event of frmmain?
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    Just noticed the part about only occurring in the exe so the IDE option would not help you there.

    Are you building the exe on that same machine?
    If not then what are you building it on?
    If yes does it run ok in the IDE?
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Sep 2012
    Posts
    4

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    I am building the exe on winxp machine and running it on win7-32bit machine
    After adding the line of code suggested, now i actually get an error with description as below
    339 Component 'comdlg32.ocx' or one of its dependencies not correctly registered: a file is missing or invalid

    As mentioned before it is WIN7 32Bit machine, i think if find this component and registered it on the machine. Can you guide me where i can find this command to register?

    how do i include this component in the app so it automatically registers itself when i run the exe on win7 machine?

  9. #9
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    [quote]Here is the code that gives that error
    Code:
    Login_Exit:
    On Error Resume Next
    Exit Sub
    Login_Err:
    MsgBox Errors.Count
    Never use on error resume next .remove this line .and look the error . that is the main reason of the issue .
    After adding the line of code suggested, now i actually get an error with description as below
    339 Component 'comdlg32.ocx' or one of its dependencies not correctly registered: a file is missing or invalid

    As mentioned before it is WIN7 32Bit machine, i think if find this component and registered it on the machine. Can you guide me where i can find this command to register?
    yes just copy comdlg32.ocx into the system32 folder .and register from dos prompt .using regsvr32 comdlg32.ocx .
    how do i include this component in the app so it automatically registers itself when i run the exe on win7 machine?
    you need to make setup package for it . hope it might help

  10. #10
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB6 Program on Win7 32bit machine Run time error msg 0

    Yes you can manually register the file but that may not be the only one. You should create an installer package using the package and deployment wizard then install the program on the target pc
    Always use [code][/code] tags when posting code.

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