Help with wierd/unexplainable error

D

Devin Linnington

Hi, I'm doing a simple program that worked fine but when i started to debug
it with sample data, I stumbled upon an error that I can't possibly explain.
It apears that while to compile this paticular function, when it reaches the
'GoTo 6' (as in goto label 6) it thinks there is no label 6 in the function
(It gives me the error 'label not defined') . This is obviously not the case,
just look at the code below!


2:
If xarg <= x(1) Then GoTo 4
If xarg >= x(n) Then GoTo 5
GoTo 6 <== where
it reaches error
3:
If xarg >= x(1) Then GoTo 4
If xarg <= x(n) Then GoTo 5
GoTo 6
4:
flagr = y(1)
End Function
5:
flagr = y(n)
End Function

' Determine value of max1
6: <== supposed
to go here....
Select Case l
Case 1
GoTo 10
Case 2
GoTo 20
End Select


Ignoring the comments and variables, it's pretty easy to see that there is
indeed a label 6 right there! I have other labels that it has to go through
earlier in the code, and they are writen in the same fashion as the '6:' one.
I have totally run out of options of what I can do here, as even changing the
'6' to something else doesn't fix the problem. Also, it is a compiler error
so that the function doesn't even run. What really gets me is that all I did
was change the variables being entered into the function, so somehow that
affected the compiler and now it doesn't like that label (note that it did
work for other values). I'm really stuck now, I just don't know what is going
on!
 
D

Dave

that is because 6 is after two 'end function' lines, so it never gets there.
change the 'end function' to 'exit function' if you want to exit without
ending
 
D

Devin Linnington

LOL! *smacks forehead* Yeah, I changed those from some other function before
entering in the new data :p Thanks a bunch!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top