Posted: Mon Oct 03, 2005 11:00 pm Post subject: pointes in VB
how to make a pointer in VB.
Also, how do you pass by reference in VB?
Sponsor Sponsor
wtd
Posted: Tue Oct 04, 2005 1:12 am Post subject: (No subject)
VB6 or VB.NET?
For VB.NET, to pass by reference, you'd have something like:
code:
Sub Foo(ByRef a As Integer)
' ...
End Sub
Pointers you don't really have.
Monstrosity_
Posted: Tue Oct 04, 2005 12:01 pm Post subject: Re: pointes in VB
liangchenen wrote:
how to make a pointer in VB.
Also, how do you pass by reference in VB?
In VB6 (not sure about .NET) there are three undocumented functions
VarPtr: Gives the memory address of a variable
StrPtr: Gives the memory address of the contents of a string
ObjPtr: Gives the memory address of the object
liangchenen
Posted: Tue Oct 04, 2005 2:45 pm Post subject: (No subject)
what if I have something like this:
code:
void add( int a [500]. int b[500])
{
int x;
for (x=0;x<500;x++)
{
a[x] += b[x];
}
}
int main()
{
int num1[500];
int num2[500];
add (num1,num2);
return 0;
}
This is code in C++, in the function, I pass the pointer of the array num1[500] and num2[500] into the function, so, when I add a[500] and b[500], I am actually manipulate arrays num1 and num2.
Can you show me how it is done in VB6.?
thx a lot
wtd
Posted: Tue Oct 04, 2005 4:45 pm Post subject: (No subject)
Google is your friend, as is MSDN.
Monstrosity_
Posted: Tue Oct 04, 2005 7:48 pm Post subject: (No subject)
liangchenen wrote:
I pass the pointer of the array num1[500] and num2[500] into the function, so, when I add a[500] and b[500], I am actually manipulate arrays num1 and num2.
Can you show me how it is done in VB6.?
thx a lot
In this case you dont need to worry about pointers, just as wtd had mentioned earlier, look up how to pass by refrence instead of by value.