Click to See Complete Forum and Search --> : VB Procedures


mohamedriji
August 25th, 2001, 05:10 AM
Is it possible to return two different values for a VB procedure.If so please send me a sample procedure code.

deghost
August 25th, 2001, 02:24 PM
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!
----------

Cimperiali
August 27th, 2001, 02:50 AM
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