|
-
Nov 29th, 2000, 02:32 AM
#1
Thread Starter
Frenzied Member
In C++, you can pass a parameter to a function using &
so that the parameter you pass it is actually modified
and you do not have to return that parameter.
Like this:
Code:
void Function(int &x){
x = 100;
}
Then if you say:
Code:
int a;
Function(a);
Then a is actually 100 now.
Well, how do you do this in VB?
-
Nov 29th, 2000, 02:44 AM
#2
Will this work for you?
Try this.
Function Test(x)
x = 100
End Function
dim y
test y
'Now y=100
-
Nov 29th, 2000, 03:05 AM
#3
Thread Starter
Frenzied Member
OK. I didn't realize it was that simple in VB.
Thanks
-
Nov 29th, 2000, 03:05 AM
#4
Frenzied Member
What you are talking about is passing variables by reference instead of by value - that's what the x& is, a reference to x.
In VB you use ByVal and ByRef to achieve the same thing. You've probably seen this in the declaration of API function calls.
For example:
Code:
Public Sub SetTo100(ByRef x As Integer)
Harry.
"From one thing, know ten thousand things."
-
Nov 29th, 2000, 03:20 AM
#5
Thread Starter
Frenzied Member
That's exactly what I'm talking about.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|