Runt-time error 0
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Runt-time error 0

  1. #1
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    121

    Runt-time error 0

    When i start the .exe and click the first time the listview, it starts the calculation for that period and al works fine.
    Direct after ending the calculation i chose an other company and click the listview again. Then i get the error.
    Sorry, i do not know how to post the code on the right way. I found out!
    Thans for your help.

    Herman

    Code:
    Private Sub LvTijdvakken_Click()
       ' On Error GoTo Foutje
       'On Error Resume Next
        
        LvTijdvakken.HideSelection = False
        If Val(LvTijdvakken.SelectedItem.Text) <= 0 Then
            Exit Sub
        End If
        Z = LvTijdvakken.SelectedItem.Index
        If Z < 1 Or Z > LvTijdvakken.ListItems.Count Then Exit Sub
        If GetSetting("HataSal", "LoonRun", "Vakantiegeld") > "" Then
           ' 'debug.print GetSetting("HataSal", "LoonRun", "Vakantiegeld")
            DeleteSetting "HataSal", "LoonRun", "Vakantiegeld"
        End If
        frmLoonberekeningStart.txtLoonTijdVak(0) = LvTijdvakken.SelectedItem.Text
        frmLoonberekeningStart.txtLoonTijdVak(1) = LvTijdvakken.SelectedItem.SubItems(1)
        frmLoonberekeningStart.txtLoonTijdVak(2) = LvTijdvakken.SelectedItem.SubItems(2)
        VulWerknemersListBox
        Bewerking = "LvTijdvakken_Click 01 "
        
        frmLoonberekeningStart.cmdTijdvakAkkoord.Enabled = True
        frmLoonberekeningStart.cmdTijdvakVerijderen.Enabled = True
        Temp1 = Trim(Left(frmLoonberekeningStart.txtLoonTijdVak(0).Text, 2))
        LoonBestand = WgBestandsPad & "\lonen" & Temp1 & "." & Trim(SalarisJaar)
        If FileExist(LoonBestand) Then
            frmLoonberekeningStart.cmdTijdvakAkkoord.Caption = "Bewerken"
            frmLoonberekeningStart.FrameBerekenenWerknemers.Visible = False
            frmLoonberekeningStart.Label1.Visible = True
        Else
            frmLoonberekeningStart.cmdTijdvakAkkoord.Caption = "Aanmaken"
            frmLoonberekeningStart.FrameBerekenenWerknemers.Visible = True
            frmLoonberekeningStart.Label1.Visible = False
        End If
    
        If Val(frmLoonberekeningStart.txtLoonTijdVak(0).Text) = Val(Wg.VakGeldBetalen1) Then
            If Not IsDate(LvTijdvakken.SelectedItem.SubItems(4)) Then
                frmVakantiegeld.Show
                frmLoonberekeningStart.Enabled = False
            End If
        End If
    
        If Val(frmLoonberekeningStart.txtLoonTijdVak(0).Text) = Val(Wg.VakGeldBetalen2) Then
            If Not IsDate(LvTijdvakken.SelectedItem.SubItems(4)) Then
                frmVakantiegeld.Show
                frmLoonberekeningStart.Enabled = False
            End If
        End If
        If WekenControle = False Then
            Unload frmLoonberekeningStart
            Set frmLoonberekeningStart = Nothing
            OpenMenu
        End If
    Exit Sub
    Foutje:
    Foutmeldingen
    
    End Sub
    Last edited by HermanTabbert; January 23rd, 2014 at 04:23 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,949

    Re: Runt-time error 0

    Comment out all the Error Traps 'On... and try it. I think it's failing at the end...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,813

    Re: Runt-time error 0

    There is no end sub line shown. If that is missing then of course it will fail.

    The On Error Resume Next would suppress any run time error so if you are getting an error there it would be a compile error and not a run time error.

    What is the actual error message you are receiving
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    121

    Re: Runt-time error 0

    David
    Indeed when i remove the error traps it works ok.
    BUT, now there is no error trap!

    DataMiser
    Sorry i missed a part of the code. That is corrected now.

    How can i include in this sub a error trapping, without getting error 0 ?

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,813

    Re: Runt-time error 0

    I think you need to describe better what you are seeing, if you are getting an error message tell us what the actual error message is. I can't determine anything by what you have posted.

    BTW there is no error 0 an err number of 0 means no error occured
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    121

    Re: Runt-time error 0

    I have uploaded the error message.

    I start my program to calculate the wages for a employer .
    I select a period and calculate. No problem at all.
    When ready i go to the main menu and select a second employer, load the form where i can select the period. When selecting the period the error shows and the program stops.
    Start the program again and load the form where i can select the period. When selecting the period it works fine.
    So in short:
    start the program
    Main menu shows
    Select employer
    Load for to select period
    Select period and calculation takes place correctly
    Back to mainmenu
    Select employer
    Load for to select period
    Select period and the error shows.
    Attached Images Attached Images  

  7. #7
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,949

    Re: Runt-time error 0

    Looks like the first time, it does NOTHING! When Z= 0 (First time)
    Code:
     Z = LvTijdvakken.SelectedItem.Index
        If Z < 1 Or Z > LvTijdvakken.ListItems.Count Then Exit Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,813

    Re: Runt-time error 0

    Quote Originally Posted by HermanTabbert View Post
    I have uploaded the error message.

    I start my program to calculate the wages for a employer .
    I select a period and calculate. No problem at all.
    When ready i go to the main menu and select a second employer, load the form where i can select the period. When selecting the period the error shows and the program stops.
    Start the program again and load the form where i can select the period. When selecting the period it works fine.
    So in short:
    start the program
    Main menu shows
    Select employer
    Load for to select period
    Select period and calculation takes place correctly
    Back to mainmenu
    Select employer
    Load for to select period
    Select period and the error shows.
    There is no error 0

    There would also be a message with any runtime error

    Your screen shot appears to be a message that you are creating and displaying, no indication of any actual error and the code that displays that message is not in the code block you posted.

    If you are running in the IDE and a run time error occurs it will show you which line the error occurs on and there is always a description along with the number.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Feb 2003
    Location
    Holland
    Posts
    121

    Re: Runt-time error 0

    David,
    Indeed, the problem was
    Code:
    'Private Sub LvTijdvakken_GotFocus()
    'Debug.Print LvTijdvakken.ListItems.Count
    'If Z > 0  Then
    '    Set LvTijdvakken.SelectedItem = LvTijdvakken.ListItems(Z) 'LvTijdvakken.ListItems(3)
    'End If
    'End Sub
    When lvtijdvakken got the focus z had no value
    Took it out and placed it in the the click sub and now it works fine.
    Thank for your help.
    Herman

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center