Results 1 to 2 of 2

Thread: [RESOLVED] How to Get 2 Return values in one Function...

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Resolved [RESOLVED] How to Get 2 Return values in one Function...

    Hello Superiors.
    i want to get two output values in one Function is't possible ?.
    i am just using String data type and split the values.
    but have any other easy way to get two output values...

    actually i want to checking a folder how many jpg files are Horizontal and vertical
    so
    Code:
    Public Funtion HVChecking() as string
     Dim HCount%, VCount%
      '' 
      ''
      ''
      ''
      Return HCount.ToString & "|" & VCount.ToString
    End Function
    finally i split the values with "|" character...


    have any other options to get two values as separate in one functions .....

    i have no moew idea about Dictionary, HashTable.....which one is best for this....

    Thanks........

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How to Get 2 Return values in one Function...

    You can return two or more values from a function by creating a Structure and let the function return it, like this example
    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Structure sCount
    4.         Public HCount As String
    5.         Public VCount As String
    6.     End Structure
    7.  
    8.     Private Function HVChecking() As sCount
    9.         Dim s As sCount
    10.  
    11.         '
    12.         '
    13.         '
    14.         s.HCount = "90"
    15.         s.VCount = "80"
    16.  
    17.         Return s
    18.  
    19.     End Function
    20.  
    21.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    22.         Dim s As sCount = HVChecking()
    23.         Me.Text = s.HCount & " --- " & s.VCount
    24.     End Sub
    25.  
    26. End Class



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width