I would like to use a pointer to alter the contents of a few different variables. I know how to do it in C but I was wondering if I could do it in VB?
Printable View
I would like to use a pointer to alter the contents of a few different variables. I know how to do it in C but I was wondering if I could do it in VB?
you can do like
VB Code:
intABC= intDEF
-Dimava
Not directly.
You can pass argumanets to functions ByVal or ByRef but that's it, I believe.
And for more reference...if you pass a variable as "ByRef"(which is the default), and when you change the value of that variable, it'll effect the actual variable passed to the function. On the other side, if you pass a variable as "ByVal", the function makes a copy of that variable into the memory and works with that. It does not effect the actual variabel passed to the function.
This kind of stuff is similar to pointers but not as powerful as they are.
There are also a handful of undocumented functions that will allow you to deal with pointers in VB.
ObjPtr
VarPtr
StrPtr (or maybe it's StringPtr)
In the MSDN, there a complete book called "Hardcore Visual Basic" (by Bruce McKinney). This has some pretty indepth discussions on how to use these fucntions in VB without blowing away your machine.
- gaffa
Play around with those and CopyMemory and you can use pointers, but I don't think it's very practical for most purposes. From what I understand, pointers are used all the time in C++.Quote:
Originally posted by gaffa
There are also a handful of undocumented functions that will allow you to deal with pointers in VB.
ObjPtr
VarPtr
StrPtr (or maybe it's StringPtr)
In the MSDN, there a complete book called "Hardcore Visual Basic" (by Bruce McKinney). This has some pretty indepth discussions on how to use these fucntions in VB without blowing away your machine.
- gaffa
If I want pointers (so I can do things like linked lists, etc), I just make class modules. Object variables act just like pointers. It's probably not very efficient, but it works.
How do you apply that?
I am trying to design a tree structure... So how can I point to another node? What do you suggest me?