|
-
Mar 26th, 2000, 11:03 AM
#1
Thread Starter
PowerPoster
Hi there,
I was wondering if there's a solution to make pointers in VB... It should be with Types because I can't use classes (problems copying them). Well, I did something like this:
Code:
Type tObject
x As Long
y As Long
Inventory() As tObject
End Type
As you can see I can't use it because of circular declaration . If anyone knows how to make this OR to make this with classes, please help me:
Code:
'Copy values to Object(0), don't link!
Object(0) = Object(1)
Thanks in advance
-
Mar 27th, 2000, 06:30 AM
#2
Hyperactive Member
have you ReDimmed the array to the size you want first?
because if you haven't, it won't work 
otherwise, it should. im doing something similar in my RTS and it works
buzzwords are the language of fools
-
Mar 27th, 2000, 10:43 AM
#3
Thread Starter
PowerPoster
Of course I did 
Well, the problem's that if I have classes and I do something like Object1 = Object2, it does not copy the values but link both objects...
Anyway, that's not the point. So is there a way to make pointers to types? I need to do this because I want to have objects in the object type, for example an inventory.
As you can see in my first post, first code lines, I have an array of objects in the type I'm declaring there... And that doesn't work (You can say I need linked lists)
-
Mar 28th, 2000, 04:49 AM
#4
Hyperactive Member
what????!!!
i don't actaully understand what you want to do
you *can* copy types by simply doing me(1) = me(0)
as long as they are the same type
buzzwords are the language of fools
-
Mar 28th, 2000, 10:57 AM
#5
Thread Starter
PowerPoster
Yes, I know... but not classes!
And I also cannot make pointers to types what is actually my problem.
OK, here's again what I want to do:
Code:
Type tObject
Contained(10) As tObject
End Type
Do you see that it doesn't work?
Well I thought I can make it having a pointer to an object in the type, like a linked list.. so is there a way?
(Or do you know another solution? Currently I just habe a big array and store the indexes instead of the objects itselves to simulate contained objects)
-
Mar 31st, 2000, 03:09 AM
#6
Hyperactive Member
well, no, you can't have a member of a type as the type itself; that really wouldn't work 
but why do you even want to have members of a type as the type itself?
wouldnt u want:
Type TObject
ID as integer
Weight as integer
Type as byte
end type
etc...
-
Mar 31st, 2000, 09:36 AM
#7
Thread Starter
PowerPoster
Well, I thought about linked lists you know... and I need it for the inventory (so an object can containt objects).
However, I just wanted to know if I can use pointers for types 
Ok then, thx for trying to help... I found a solution ages ago, just wanted to know if there's another way to make it.
-
Mar 31st, 2000, 07:51 PM
#8
Frenzied Member
I've just read that conversation and have no Idea what you're trying to do, but if you want to get a pointer to a Variable use VarPtr(uMyVariabe) this will give you a long pointer to your variable, see my VarPtr post for an example of how to use it
-
Mar 31st, 2000, 09:03 PM
#9
Thread Starter
PowerPoster
Thanks Sam, I can need this for another problem
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
|