Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:44:58+00:00 2026-05-25T06:44:58+00:00

Hi Please can someone show me how to return multiple values from a function?

  • 0

Hi Please can someone show me how to return multiple values from a function? I have my function in a seperate file within App_Code and here it is:

Public Function GetQuoteStatus(ByVal QuoteID As String) As String 

Dim quoteStatus As String

Dim con As New SqlConnection  
Dim cmd As New SqlCommand  

Try  
    con.ConnectionString = ConfigurationManager.AppSettings("quotingSystemConnectionString")  
    con.Open()  
    cmd.Connection = con  
    cmd.CommandText = "SELECT Status FROM Quote WHERE QuoteID =" & QuoteID & ";"  
    Dim lrd As SqlDataReader = cmd.ExecuteReader()  

    While lrd.Read()  
        quoteStatus = lrd("Status")  
    End While  

Catch ex As Exception  

Finally  
    con.Close()  
End Try  

Return quoteStatus

End Function

To get the returned quoteStatus from within another vb file in my site I would normally use:

Dim statusHelper As New quoteStatusHelper()
Dim quoteStatus As String = statusHelper.GetQuoteStatus("QuoteID")

However this is all good and well for one returned value but what If I wanted to return multiple values… How do I access them?

Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:44:58+00:00Added an answer on May 25, 2026 at 6:44 am

    You could use

    Public Function GetQuoteStatus(ByVal QuoteID As String) As String()
    

    This let you return a string array, so there is no limit to data you can have.
    The cons is you have to parse the array.

    You could even use

    Public Function GetQuoteStatus(ByVal QuoteID As String, 
        Byref Second As String) As String
    

    This let you return a string as result and set the value of another var (Second); you can use more than one Byref variables to return multiple values…
    The cons is that you have to statically declare your function and modifiy all previous calls. In this case the use of refactoring is reccomended!

    EDITED:
    You could even return a class for example.
    Declare a class that fits your needs (with all the fields, getters, setters and constructors) and inside your function you could create an instance of that class, fill every field and return this class.
    Easy to implement, easy to use.

    EDITED AGAIN:

    Public Class MyClass
        Public Property Val1 As String
        Public Property Val2 As String
        Public Property Val3 As String
    
        Public Sub New(ByVal newVal1 As String, ByVal newVal2 As String, ByVal newVal3 As String)
            Val1 = newVal1
            Val2 = newVal2
            Val3 = newVal3
        End Sub
    End Class
    
    Public Function GetInfo() As MyClass
        Dim mc As New MyClass("test1", "test2", "test3")
        Return mc
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please show me how to use prepareForReuse? I have been searching for
In WPF: Can someone please explain the relationship between DependencyProperty and Databinding? I have
Can someone please point me to the easiest way to have a timer in
Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how
Can someone please show me the easiest way to create/update a parent and child
Can someone please point me to articles or books that discusses different programming paradigm
Can someone please let me know how to get the different segments of the
Can someone please explain me what's the difference between Swing and AWT? Are there
Can someone please explain why int (0.4 * 10.0) is 4 yet int ((2.4
Can someone please help me out with printing the contents of an IFrame via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.