|
-
May 30th, 2001, 02:20 PM
#1
Thread Starter
Junior Member
Pointers in VB?
I've looked through help files, and I cant find a convention for creating a pointer to any kind of oblect type. What am i missing?
Lets suppose I have an object Foo. What statement will declare a variable that is a pointer to an object of type Foo?
-
May 30th, 2001, 02:23 PM
#2
Frenzied Member
easy answer
vb has no pointers
-
May 30th, 2001, 02:27 PM
#3
There are function such as VarPtr, or ObjPtr which will allow you to get the address of variables, but they won't act as pointers, in the sense that C++ dos.
-
May 30th, 2001, 02:37 PM
#4
There are three undocumented 'pointer' functions
StrPtr, VarPtr, ObjPtr, plus AddressOf mostly for functions.
But as Mega said, they aren't like C pointers. And they are undocumented for a reason - you can trash your system in a hurry with them.
-
May 31st, 2001, 01:58 AM
#5
Lively Member
VB doesn't have pointers in the true sense that C does, but it does do almost the same thing.
Whenever you declare something of a user defined type say
Dim x as MyObjectType
you are not really creating an object, more a pointer to an object of the specified type which is effectively set to be NULL. This is why you cant actually call any of the member functions of x after the above declaration.
The declaration
Dim y as New MyObjectType
declares a new object of MyObjectType and has y pointing to it.
In essence the declarations
Dim x as MyObjectType
Dim y as New MyObjectType
are effectively the same as the following C declarations
MyObjectType* x = NULL;
MyObjectType* y = new MyObjectType;
The main difference in the long run is that if you want to call member functions
in VB:
result = y.func(a,b,c)
in C:
result = y->func(a,b,c);
Hopefully at least some of this makes sense, and if I am spinning crap then I'm sure someone will correct me.
-
Jun 7th, 2001, 02:52 AM
#6
Lively Member
Did anyone have an opinion on this??
Just wondering if anyone had anything to say about my previous post, as to whether I was talking rubbish or not. Please feel free to let me know if I am deluding myself with my view of VB and pointers.
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
|