Results 1 to 5 of 5

Thread: [RESOLVED] Stumped -- Compiled executable errors, debug fine.

  1. #1

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Resolved [RESOLVED] Stumped -- Compiled executable errors, debug fine.

    I can't figure this one out. I get a subscript out of range error in the compiled executable that I'm not getting in the IDE. The error handler that fires is in this routine:
    Code:
    Private Sub HeaderConfigure()
    
        Dim lWidth As Long, lIndex As Long
    
        On Error GoTo ErrHand
        MsgBox "NUM_OFFER_COLS = " & NUM_OFFER_COLS
    
        'Note.  If the number of elements in this array changes, NUM_OFFER_COLS should be updated.
        With lstOffers
            .ListItems.Clear
            .ColumnHeaders.Clear
            For lIndex = LBound(csColumns) To UBound(csColumns)
                If lIndex > NUM_OFFER_COLS Then Exit For
                lWidth = goOptions.GetOfferColumns(lIndex)
                If lWidth < 0 Then lWidth = DEFAULT_COL_WIDTH
                Call .ColumnHeaders.Add(lIndex + 1, , csColumns(lIndex), lWidth)
            Next lIndex
        End With
    
    ErrHand:
        If Err.Number <> 0 Then
            Call MsgBox("Error number " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
                        "in routine HeaderConfigure of OfferTray", vbExclamation, "TrialTrack Error")
        End If
    
    End Sub
    The function uses a form level array (csColumns) to create column headers for a listview control, and sets the widths from a user options object. The problem apparently doesn't lie in the widths, as when I comment out that line I get the same result. Interestingly, the message box that I stuck in to try and track the problem down is never displayed. I also tried removing the error handler and compiling it, and it did exactly the same thing. Any ideas?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Stumped -- Compiled executable errors, debug fine.

    Some questions
    1. Is LBound(csColumns) always zero? If not, don't believe you can .Add beyond header count+1
    2. in goOptions class, do you have error handling in the GetOfferColumns routine? If so, that could explain why the msgbox is not fired as expected.
    3. in goOptions, does GetOfferColumns use an array also? Could the error be happening in there?

    Why it is happening compiled vs IDE is interesting, but probably not that important at this point.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Stumped -- Compiled executable errors, debug fine.

    Quote Originally Posted by LaVolpe
    Some questions
    1. Is LBound(csColumns) always zero? If not, don't believe you can .Add beyond header count+1
    2. in goOptions class, do you have error handling in the GetOfferColumns routine? If so, that could explain why the msgbox is not fired as expected.
    3. in goOptions, does GetOfferColumns use an array also? Could the error be happening in there?

    Why it is happening compiled vs IDE is interesting, but probably not that important at this point.
    1.) csColumns is created by splitting a string in the form's initialize event, so it would always have a 0 LBound. I use the same code in a different form as well, and that one works perfectly.
    Code:
    Private Sub Form_Initialize()
    
        On Error GoTo ErrHand
    
        If Not geDevMode Then
            Call SetIcon(Me.hWnd, INTRAY_ICON, False)
        End If
        
        csColumns = Split("Trial Number,Client Name,Offer Date,Offer Type,Underwriter,Broker", ",")
        
    ErrHand:
        If Err.Number <> 0 Then
            Call MsgBox("Error number " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
                        "in routine Form_Initialize of OfferTray", vbExclamation, "TrialTrack Error")
        End If
      
    End Sub
    2-3.) The options class has an error handler (probably doesn't need one as it's a trivial function):
    Code:
    Public Function GetOfferColumns(lColumn As Long) As Long
    
        On Error GoTo ErrHand
    
        If lColumn <= UBound(clOfferColWidth) Then
            GetOfferColumns = clOfferColWidth(lColumn)
        End If
    
    ErrHand:
        If Err.Number <> 0 Then
            csError = vbCrLf & "Error number " & Err.Number & vbCrLf & Err.Description
            Err.Clear
            Call Err.Raise(vbObjectError, "UserOptions", "UserOptions GetOfferColumns failed." & csError)
        End If
    
    End Function
    I know that the clOfferColWidth array is being filled and written properly, because the registry setting is created correctly when the program starts and it returns correctly from other places in the code. I alse get the same behavior when that line of code is removed as well.

    What is strange is that the error seems to happen before any arrays are accessed.

    [EDIT] BTW the first thing I tried was compiling with all of the optimization flags turned off, same result.

  4. #4

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Stumped -- Compiled executable errors, debug fine.

    Freaky . This resolved itself when I changed the variable name from lIndex to lColumn. I double checked that lIndex is never used higher than procedure level scope (it wasn't). Looks like a compiler aliasing error. Thanks LaVolpe.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] Stumped -- Compiled executable errors, debug fine.

    This is going to sound like a weird question. In your classes, do you have any that return DOUBLE vartypes, either as arrays or non-arrays? This is beginning to sound like a situation I had once.
    Edited: Ignore that last question then. I wonder if you asked for class parameter byval if the error would have also gone away; but don't fix it if it ain't broke.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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