The VB 6.0 way was to assign the function name to a value. In .NET, you
use: "Return someValue".
So,
Return Roll
....and...
RollDie = Roll
would return the same value (in your second example you didn't set the
function equal to anything, so you would get any value from your second
version).
The difference between the two is that "Return" not only set the value of
the function, but it also exits from the function after it executes, so any
code written after Return will not run, whereas by setting the return value
= to something where all the code will run up to the End Function statement.
For example:
Function RollDie As Integer
Dim Roll As Integer
Dim y as new Random
Roll = y.next(1,6)
Return Roll
'This next line will never execute because the function will "Return"
control back to the calling procedure after the above line.
Dim x as String = "Test"
End Function
Also note the use of the new .NET Random class and its next method as
opposed to the VB 6 Randomize() and Rnd() functions.
"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
I am curious as to why ASP.NET returns values a different way from VB or
VB.net (or can you use both).
In my one book I have it returning using a return statement
************************************************** *********
function RollDie As Integer
Dim Roll As Integer
Randomize
Roll = Int(rnd * 6) + 1
Return(roll)
end function
************************************************** *********
instead of return it only with the assigment to the function name:
************************************************** *********
function RollDie As Integer
Dim Roll As Integer
Randomize
Roll = Int(rnd * 6) + 1
end function
************************************************** **********
Are both of these correct?
Thanks,
Tom.