G
Guest
I have a very simple function I'm working on.
Function CarSpeed(ByVal kph As Integer)
If kph < 0 Then
_quote = "the car is in reverse"
_actualspeed = kph
ElseIf kph = 0 Then
_quote = "the car is parked."
_actualspeed = kph
ElseIf kph > 0 And kph <= 10 Then
_quote = "the car is moving slowly."
_actualspeed = kph
Else
_quote = "the car is moving quickly."
_actualspeed = kph
End If
'New for VS 2005 apparently...
Return kph
End Function
Originally, I built this using Visual Studio .NET 2003. I just downloaded
the Visual Studio .NET 2005 express and when I initially typed in the old
code I didn't have the line "Return kph" on the original version, and I got a
warning saying, "Function CarSpeed doesn't return a value on all code paths.
A null reference exception could occur at run time when the result is used."
So why do I need to include the line "Return kph" for VS 2005?
Function CarSpeed(ByVal kph As Integer)
If kph < 0 Then
_quote = "the car is in reverse"
_actualspeed = kph
ElseIf kph = 0 Then
_quote = "the car is parked."
_actualspeed = kph
ElseIf kph > 0 And kph <= 10 Then
_quote = "the car is moving slowly."
_actualspeed = kph
Else
_quote = "the car is moving quickly."
_actualspeed = kph
End If
'New for VS 2005 apparently...
Return kph
End Function
Originally, I built this using Visual Studio .NET 2003. I just downloaded
the Visual Studio .NET 2005 express and when I initially typed in the old
code I didn't have the line "Return kph" on the original version, and I got a
warning saying, "Function CarSpeed doesn't return a value on all code paths.
A null reference exception could occur at run time when the result is used."
So why do I need to include the line "Return kph" for VS 2005?