Results 1 to 9 of 9

Thread: A bug in VB?... or something else?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176

    A bug in VB?... or something else?

    I've got a problem with my project. The application is about 5 years old and has been in constant development throughout that time. Today though, I've started getting a weird error. Error 16, expression too complex.

    The line it breaks on is:
    Code:
    ScrollIncrement = 1
    ScrollIncrement is a long integer variable which is private to the sub.

    According to MSDN, this shouldn't happen. Has anyone else come across this problem before?

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: A bug in VB?... or something else?

    Nope.


    Try changing the value and see what happens.

    Is the scrollbar enabled? Visible? Are the limits more than the incriment value apart from each other?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176

    Re: A bug in VB?... or something else?

    ScrollIncrement isn't a scrollbar. It's a variable.

    The code hasn't changed in that sub at all.

    The only code I added is this:
    VB Code:
    1. ReDim ExpandedInvoices(0)
    2.     If MemoriseExpanded = True Then
    3.         If (Not MasterList) <> -1 Then
    4.             For i = 0 To UBound(MasterList) - 1
    5.                 If MasterList(i).Expanded = True Then
    6.                     If MasterList(i).Type = InvoiceHeader Then
    7.                         ExpandedInvoices(UBound(ExpandedInvoices)) = MasterList(i).InvoiceNumber
    8.                         ReDim Preserve ExpandedInvoices(UBound(ExpandedInvoices) + 1)
    9.                     End If
    10.                 End If
    11.             Next
    12.         End If
    13.     End If

    This is in a different sub which is called before the one with the error. If I comment out this section of code the error goes away...

    ...but if I step through that code (using f8) the error doesn't occur then either.

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: A bug in VB?... or something else?

    This line looks suspect to me. What data type is MasterList, and what are you trying to achieve with this code?


    VB Code:
    1. If (Not MasterList) <> -1 Then
    This world is not my home. I'm just passing through.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176

    Re: A bug in VB?... or something else?

    MasterList is a dynamic array of a UDT. That line just checks it to see if it's been dimensioned or not.

  6. #6

  7. #7
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: A bug in VB?... or something else?

    Do you have Option Explicit everywhere ?

    What happens if you use -
    Run Start with full compile,
    instead of
    Run Start
    Rob C

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: A bug in VB?... or something else?

    I had the same problem before, and the problem is with this line:
    VB Code:
    1. If (Not MasterList) <> -1 Then

    Find another way to get if the array is redimmed or not...
    Try something like this:
    VB Code:
    1. On Error Resume Next
    2. dummyval = MasterList(LBound(MasterList))
    3.  
    4. If Err.Number = 0 Then
    5.    ' dimmed
    6. Else
    7.    ' array empty (erased)
    8. End If

  9. #9

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