Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return 2 values from a function
Message
De
15/10/2008 15:40:23
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
15/10/2008 15:01:46
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01355203
Message ID:
01355226
Vues:
19
In VB.NET, these are used like so (note the ByRef instead of ByVal):
Sub Main
   Dim value1 As Integer = 1
   Dim value2 As Integer = 2

   FlipValues(value1, value2)

   'value1 now equals 2
   'value2 now equals 1
End Sub

Sub FlipValues(ByRef firstValue As Integer, ByRef secondValue As Integer)
   Dim tempValue As Integer = firstValue
   firstValue= secondValue
   secondValue= tempValue
End Sub
However, I would tend to agree with Paul that you should use a Structure. Like John said, a Function should return a single value. A Structure qualifies as a single value.

>Hi Daniel,
>
>In addition to John and Paul's info, if you really need multiple return values, you can use "out" parameters.
>
>Bill
>
>>Hi All,
>>
>>I need to return 2 values from a VB.NET function. One is data type integer and the other string.
>>What is the best approach to acomplish that?
>>
>>Thanks,
>>Daniel
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform