M
Mehul Malhotra
Hi I just wanted to know how to create a function that
passes more than one variable back if possible?
Thanks a lot
passes more than one variable back if possible?
Thanks a lot
* "Mehul Malhotra said:Hi I just wanted to know how to create a function that
passes more than one variable back if possible?
* "Bernie Yaeger said:As is demonstrated in Herfried's example, any variable that is passed byref
will come back changed as however it may have been changed inside the
function. This is true in subs as well.
I though you where living in the London area?If P.Age < 21 Then
P.Name="Too Young"
Hi OHM,
I though you where living in the London area?
)
Cor
* "One Handed Man said:Alternatively, you might want to assign a new reference to an object. For
example.( Members declared public for brevity only ).
Class Person
Public Age as Integer
Public Name as String
End Class
Public Function TooOld( ByRef P as Person ) As Person
If P.Age < 21 Then
P.Name="Too Young"
Return P
Else
Return P
End If
End Function
* "One Handed Man said:Duh !!!. I just realised what you meant by that,maybe I should have written
the following.
If P.Age < 18 Then
P.Name="Too Young To Vote!"
* "One Handed Man said:The OP's question was to find out how a function could return more than one
peice of data. Allowing the parameters passed to be changed does not
address that question.
* "One Handed Man said:Funnily enough, My son ( 13 and a half ) has started to learn VB.NET and
he's working through a step-by-step book, amazingly he is grasping the
concepts very quickly and is demonstrating this by augmenting the examples
and labs for himself.
* "One Handed Man said:Why bother using a structure, I dont see any benefit. After all, you can do
so much more with a class.
* "Cor said:I think that Herfried, means why do you do it like this
And not just
Public Function TooOld( ByVal P as Person ) As Person
I also do not like ByRef, (and read the thread this time good)