Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to return multiple values from a function in VB.NET

4 Answers

0 votes
Imports System

Public Class Test
    Public Shared Function f(ByRef a As Integer, ByRef b As Integer, ByRef c As Integer)
        a = 435
        b = 89
        c = 1
    End Function
    
    Public Shared Sub Main()
        Dim a As Integer
        Dim b As Integer
        Dim c As Integer
         
        f(a, b, c)
        
        Console.WriteLine("a = {0} b = {1} c = {2}", a, b, c)
    End Sub
End Class



' run:
' 
' a = 435 b = 89 c = 1
'

 



answered Aug 8, 2019 by avibootz
0 votes
Module Module1

   Function f() As Tuple(Of Integer, Integer, Integer)
        Return New Tuple(Of Integer, Integer, Integer)(723, 89, 8262)
    End Function

    Sub Main()
        Dim t As Tuple(Of Integer, Integer, Integer) = f()
        
        Console.WriteLine(t.Item1)
        Console.WriteLine(t.Item2)
        Console.WriteLine(t.Item3)
    End Sub

End Module



' run:
'
' 723
' 89
' 8262
'

 



answered Aug 8, 2019 by avibootz
edited Aug 9, 2019 by avibootz
0 votes
Module Module1

   Function func() As Tuple(Of Integer, Integer, Integer)
        Dim a As Integer = 90
        Dim b As Integer = 3
        Dim c As Integer = 872
        Return New Tuple(Of Integer, Integer, Integer)(a, b, c)
    End Function

    Sub Main()
        Dim t As Tuple(Of Integer, Integer, Integer) = func()
        
        Console.WriteLine(t.Item1)
        Console.WriteLine(t.Item2)
        Console.WriteLine(t.Item3)
    End Sub

End Module



' run:
'
' 90
' 3
' 872
'

 



answered Aug 8, 2019 by avibootz
edited Aug 9, 2019 by avibootz
0 votes
Imports System

Public Class Program
	Public Shared Function getValues() As Tuple(Of Integer, Integer)
        Dim a As Integer = Int32.MaxValue, b As Integer = 345

        Return Tuple.Create(a, b)
    End Function

    Public Shared Sub Main()
        Dim result = getValues()
	
        Console.WriteLine("{0}, {1}", result.Item1, result.Item2)
    End Sub
End Class




' run:
'
' 2147483647, 345
'

 



answered Dec 19, 2021 by avibootz

Related questions

1 answer 196 views
2 answers 245 views
2 answers 268 views
1 answer 147 views
...