CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: VB Procedures

  1. #1
    Join Date
    Jul 2001
    Posts
    5

    VB Procedures

    Is it possible to return two different values for a VB procedure.If so please send me a sample procedure code.


  2. #2
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: VB Procedures

    you can use "ByRef"


    Sub Return2Values(byval a as Integer, byval b as Integer, byref ret1 as Integer, byref ret2 as Integer)
    ret1 = a * b
    ret2 = a \ b
    End Sub

    private Sub Form_Load()
    Dim a as Integer
    Dim b as Integer
    Return2Values 5, 2, a, b
    MsgBox a & " " & b
    End Sub




    ----------
    The @host is everywhere!
    ----------

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: VB Procedures


    Another way:
    private function somevalues(byval inP1 as integer, byval inP2 as integer) as variant
    inp1 = inp1+1
    inp2= inp2+1
    somevalues= array(inp1,inp2)
    end function

    private sub form_load()
    dim p1 as integer, p2 as integer
    dim retval
    retval = somevalues(p1,p2)
    msgbox retval(0) & " " & retval(1)
    end sub




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured