Last post Sep 15, 2012 12:25 PM by mbanavige
Sep 15, 2012 12:11 PM|JAYHAWKER|LINK
If I have the following function:
Public Shared Function Previous(ByRef Var1 As System.Object, ByRef Var2As System.Object, )
How do I return the two ByRef variables?
return (var1, var2)?
Sep 15, 2012 12:16 PM|mbanavige|LINK
you do not return them. since they were passed ByRef, changes you make to them are automatically visible on the original variables that were passed in.
Sep 15, 2012 12:18 PM|JAYHAWKER|LINK
So when I do a return(e) at the end of the function, I am actually wasting my time in doing so? Is that right?
Sep 15, 2012 12:25 PM|mbanavige|LINK
some functions that take args ByRef still have a return value.
for example, Int32.TryParse returns True/False to indicate if the parse was successfull and the actual parsed value lands in the int value that was passed in as an argument.
depending on what you're doing, you may or may not need an explicit return value, but it has no bearing on what you do with the args that were passed ByRef.