I am new to VBScript, and I learned that VBScript does not have return
and that to return a value, you assign the value to the name of the procedure.
When I was doing research on how to return a value, I found two different programs that both return a value, and I am not sure what the difference is.
Function Test1()
Dim value
'Do something'
If value < 10 Then
Test1 = value * 2
Else
Test1 = value
End If
End Function
Function Test2()
Dim value
'Do something'
If value < 10 Then
Test2 = value * 2
Exit Function
Else
Test2 = value
Exit Function
End If
End Function
It seems like Exit Function
exits the procedure immediately when this program comes to this line, but what is the necessity of this line of code?
I have been learning other major programming languages such as C#, Java, etc, and in those programming languages, once the program comes to the line return
or return something
, the program exits that function/method even if there is mode code after that.
Does this mean, in VBScript, assigning a value to the name of its own procedure serves as return
but it still keeps going without exiting until the end of the procedure unless you use Exit Function
?