* "Microsoft" <ma*@mas.com> scripsit:
Thanks for the replies. Can a fumction return more than one value in vb.net?
There are different ways to return more than one value:
\\\
Public Sub Swap(ByRef x As Integer, ByRef y As Integer)
dim t As Integer = x
x = y
y = t
End Sub
..
..
..
Dim i As Integer = 22
Dim j As Integer = 99
Swap(i, j)
MsgBox(CStr(i))
MsgBox(CStr(j))
///
- or -
\\\
Public Class CalculationResu lt
Public x As Integer
Public y As Integer
Public s As String
...
End Class
..
..
..
Public Function Calculate(...) As CalculationResu lt
Dim c As New CalculationResu lt()
c.x = ...
c.y = ...
Return c
End Function
..
..
..
Dim c As CalculationResu lt = Calculate(...)
MsgBox(CStr(c.x ))
MsgBox(CStr(c.y ))
MsgBox(c.s)
///
- or -
\\\
Public Function Foo() As String()
Return New String() {"Hello", "World"}
End Function
..
..
..
Dim astr() As String = Foo()
MsgBox(astr(0))
MsgBox(astr(1))
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>