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?
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?
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:
ReDim ExpandedInvoices(0)
If MemoriseExpanded = True Then
If (Not MasterList) <> -1 Then
For i = 0 To UBound(MasterList) - 1
If MasterList(i).Expanded = True Then
If MasterList(i).Type = InvoiceHeader Then
ExpandedInvoices(UBound(ExpandedInvoices)) = MasterList(i).InvoiceNumber
ReDim Preserve ExpandedInvoices(UBound(ExpandedInvoices) + 1)
End If
End If
Next
End If
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.
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:
If (Not MasterList) <> -1 Then
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.
Re: A bug in VB?... or something else?
Can you show the code that contains the ScrollIncrement = 1 line?
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
Re: A bug in VB?... or something else?
I had the same problem before, and the problem is with this line:
VB Code:
If (Not MasterList) <> -1 Then
Find another way to get if the array is redimmed or not...
Try something like this:
VB Code:
On Error Resume Next
dummyval = MasterList(LBound(MasterList))
If Err.Number = 0 Then
' dimmed
Else
' array empty (erased)
End If
Re: A bug in VB?... or something else?
I agreee with others: line If (Not MasterList) <> -1 Then is the beast ...
Check LBound or UBound to see if arrary is dimmed and trap error ...