Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 2nd, 2005, 07:55 PM
Registered User
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multi returning function

dear all

how can i build a function that can return 3 values...

for e.g.

public function r3v(xx as integer, yy as integer)as integer


end function

hom can i????

Reply With Quote
  #2 (permalink)  
Old March 3rd, 2005, 06:15 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

You could return an array:

public function r3v(xx as integer, yy as integer)as integer()
   Dim x(2) As Integer

   x(0) = yy
   x(1) = xx
   x(2) = yy+xx

   r3v = x
End Function

then you call it like this:

Dim ReturnArray() As Integer
ReturnArray() = c3v(99, 100)
For i = 0 To Ubound(ReturnArray)
    Debug.Print ReturnArray(i)

Or you could just add extra ByRef parameters to your function and modify them inside the function.
Reply With Quote
  #3 (permalink)  
Old March 3rd, 2005, 01:48 PM
Friend of Wrox
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts

instead of a function, create a method and declare the output variables byRef

public/private sub MySub(byval in1, byval in2,... byref out1, byref out2,...)

all the byval (by value) are [in] parameters (that is, they cannot be changed inside MySub, actually they can but when the sub returns they are left the same), and all the byref (by reference) are [out] parameters that can be modified

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Function returning an array rfstuck Pro VB 6 5 March 12th, 2008 07:35 AM
Function not returning value civa Access 5 January 17th, 2006 03:44 AM
EXEC function not returning values aingalsbe PHP How-To 0 June 1st, 2004 10:03 AM
Function not returning anything... goatboy Beginning PHP 2 December 1st, 2003 12:34 PM
Returning variables from a function starsol Beginning PHP 1 September 11th, 2003 12:58 PM

All times are GMT -4. The time now is 10:36 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.