Django Anonymous
Django Anonymous

Reputation: 3025

How to display multiple returned value of a function in .NET

I have the following Structure

Public Structure Info_Diag_Data
    Public DataOne As String
    Public DataTwo As String
End Structure

And this function uses the above class

Public Shared Function My_Function(ByVal RcvVal As Integer) As Info_Diag_Data

    Dim SendVal As Info_Diag_Data

    Select Case RcvVal
        Case 1
            SendVal.DataOne = "Red"
            SendVal.DataTwo = "Master"
        Case 2
            SendVal.DataOne = "Red"
            SendVal.DataTwo = "Teacher"
    End Select

    Return SendVal
End Function

Now i know i can execute this function using My_Function(2)

My question is how to display this data after getting these two returned values from function.

Like as i got DataOne and DataTwo in return. Then how can i show it in MessageBox.Show(DataOne) and MessageBox.Show(DataTwo)

Upvotes: 1

Views: 3307

Answers (1)

Steven Doggart
Steven Doggart

Reputation: 43743

You'll need to store the results in a Info_Diag_Data value, then you'll be able to access the various members of the object through that variable, like this:

Dim data As Info_Diag_Data = My_Function(2)
MessageBox.Show(data.DataOne)
MessageBox.Show(data.DataTwo)

Upvotes: 2

Related Questions