Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return 2 values from a function
Message
De
16/10/2008 07:35:27
 
 
À
15/10/2008 15:40:23
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
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:
01355326
Vues:
20
Hey Mike,

Ah, I didn't note the VB reference. Yes the struct or class object would be the best route. I was only trying to give another possibility to round out the options.

>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
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform