On Tue, 3 Jan 2006 19:21:52 +0100, "Herfried K. Wagner [MVP]"
<hi************ ***@gmx.at> wrote:
"Joergen Bech @ post1.tele.dk>" <jbech<NOSPAMNO SPAM> schrieb:To me it seems that they have forgotten to implement the check for 'On
Error
GoTo'...
As far as I understand it, the squiggly lines are not based on the
source text you see, but what the parser turns it into. Which in this
case is an entirely different beast. See my other post.
The occurance of the warning depends on the return type of the function. So
it's not actually a bug, but I believe the warning could have been
implemented in a way that it is also shown for functions which return a
value type.
Care to give me an example that involves On Error Goto?
It is true that the squiggly lines appear for
Public Function ObjectDoesProdu ceSquiggleLines () As Object
'Do nothing
End Function
but not for
Public Function ValueProducesNo SquiggleLines() As Boolean
Dim b As Boolean = True
End Function
But when the "On Error ..." abomination is used, as in the sample
the original poster provided ...
Check the samples below. None of them produce squiggly lines, even
though I am fairly positive that they cover both objects and value
types as return values. I see no difference in behavior due to
the choice of return types.
If you look at what the compiler turns the samples into, you will
see that something is explicitly returned on all code paths in all
samples.
---snip---
Option Explicit On
Option Strict On
....
Public Function GetString() As String
On Error GoTo someerror
Return ""
SomeError:
End Function
Public Function GetObject() As Object
On Error GoTo SomeError
Return Nothing
SomeError:
End Function
Public Function GetBoolean() As Boolean
On Error GoTo SomeError
Return False
SomeError:
End Function
Public Function GetArrayList() As ArrayList
On Error GoTo SomeError
Return New ArrayList
SomeError:
End Function
---snip---
Regards,
Joergen Bech