473,473 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need to return multiple values via same function using VB6

14 New Member
I want to return values of two arguments through a function via same argument.

Example:

(a, b) = getvalue(x, y)

Can anyone help?



T. Ashok Kumar
Jul 29 '07 #1
4 12414
kentgorrell
11 New Member
A function can only return a single value but if you were to concatenate the two values that you want to return eg-
value1 & ", " & value2
so if you pass in (x, y) and you get back "24, 25" - note the result will be a string.
Jul 30 '07 #2
joshtboy9987
5 New Member
You could pass the variables you want the function to write to by reference. (Change the function to a sub).

for example

Sub Add(a as single, b as single, ByRef c as single, ByRef d as single)

c=a+b
d=b+c

End Sub

The following code would change the values of c and d to a+b and b+c respectively.
This kind of acts like a pointer in C. Instead of sending a value to the function
it sends a address so that the program can modify the value directly...
Jul 30 '07 #3
Killer42
8,435 Recognized Expert Expert
A function can only return a single value but if you were to concatenate the two values that you want to return eg- ...
Are you sure about that? I have a feeling it might be possible for a function to return an array. Or a variant, which can contain an array.
Jul 30 '07 #4
Killer42
8,435 Recognized Expert Expert
You could pass the variables you want the function to write to by reference. (Change the function to a sub).
for example
Sub Add(a as single, b as single, ByRef c as single, ByRef d as single) ...
Just wanted to point out, arguments are passed by reference by default in VB. You only need to specify if you want to pass them by value. In other words, while you might sometimes code the ByVal keyword, there is really no need for ByRef.

As an example, these two definitions produce the same result...
Expand|Select|Wrap|Line Numbers
  1. Sub Add(a As Single, b As Single, c As Single, d As Single)
  2. Sub Add(a As Single, b As Single, ByRef c As Single, ByRef d As Single)
Jul 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
2
by: TSK | last post by:
I cannot get my focus() fn to work in my validateInput(userInput) fn. It will not allow the user to go back and correct invalid input like it should. Instead it goes right on through with the...
5
by: D. Shane Fowlkes | last post by:
This may be a very basic question but it's something I've never done before. I've looked at a couple of my favorite sites and books and can't find an answer either. I can write a Function to...
16
by: Nikolay Petrov | last post by:
How can I return multiple values from a custom function? TIA
5
by: Ghislain Tanguay | last post by:
Hi! I'm maybe from old school but, for me, whebn it's time to call a method from DCOM, remoting or web service returning a string or anything else I use a function. It's more verbose. In my new...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
18
by: SpiralCorp | last post by:
int divide (int a, int b) { int r; r=a/b; return (r); } int main () { int result = divide (20,4); cout << result
2
ADezii
by: ADezii | last post by:
The incentive for this Tip was an Article by the amazing Allen Browne - I considered it noteworthy enough to post as The Tip of the Week in this Access Forum. Original Article by Allen Browne ...
2
Dormilich
by: Dormilich | last post by:
Hi, I'm testing my classes for a web page and I stumble upon an error I don't have a clue what it means: Error: Fatal error: Can't use method return value in write context in "output.php" on...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.