|
-
Apr 27th, 2000, 06:18 AM
#1
Thread Starter
Junior Member
can you create pointers to structures like in c?
-
Apr 27th, 2000, 06:20 AM
#2
Lively Member
Uhm.. not exactly.. are you trying to make a linked list or something?
-
Apr 27th, 2000, 06:25 AM
#3
Fanatic Member
Yes and No,
You can't declare a pointer and change it's reference like in C but there are a couple of things you can do.
you can pass the type through a function by reference
and you can pass the first value in an array of types to an API function as a pointer to the whole array (like sending an array of points to the polygon API (Forget what it's called) )
What are you trying to do?
Paul
-
Apr 27th, 2000, 06:27 AM
#4
Fanatic Member
You can make linked lists with object pointers though!
But you need to investigate very thoroughly because some aspects of VB's object references are slow. but you can write double linked lists etc with them.
-
Apr 27th, 2000, 06:29 AM
#5
Thread Starter
Junior Member
i have 1 type with about 8 varables. i declared two of them t1, and t2. I want to switch back and forth be between the two. Acutually as im writint i just thought about declaring a 3rd one and just set it to equal the contents on t1 or t2. is that can i do that?
-
Apr 27th, 2000, 06:32 AM
#6
Frenzied Member
There's a VarPtr Function which returns a Pointer to a Variable, You can use the CopyMemory API To get Data Out of a pointer.
If it wasn't for this sentence I wouldn't have a signature at all.
-
Apr 27th, 2000, 06:32 AM
#7
Lively Member
What I've done for linked list type thing is make an array of a user defined type. I don't know if this is the best way to do it in VB but that how I accomplish it. Look into "Redim" and "Redim Preserve". Haven't really had to remove elements from the list so I can't tell you the best way to accomplish this.
-
Apr 27th, 2000, 06:42 AM
#8
Thread Starter
Junior Member
im not really making a linked list. I have two files one has default data and the has custom data. the defualt will alwase stay the same as the custom changes. My main Form displays the contents on the file one at a time. I have been just reloading the data each time, but my c programing started to kick in. so i created a structure to hold the data ( insed of all varables ). i want to switch between the two,i was thinking that in c i could create a pointer and just have it point to ether structure, but this is vb.
-
Apr 27th, 2000, 06:54 AM
#9
Fanatic Member
how about this.
make your two type vars public at module level.
in your app dim a new var of that type and have a sub that swaps the reference.
so your sub looks like
Sub SetPtr(LocalType, ModuleType)
LocalType = ModuleType
End Sub
Since this passes a reference your localtype can be assigned to the a difference moduleType by passing it and the module to the sub.
Just pass the module type you want to assign to it.
Or something like that
-
Apr 27th, 2000, 07:02 AM
#10
Fanatic Member
how about this.
make your two type vars public at module level.
in your app dim a new var of that type and have a sub that swaps the reference.
so your sub looks like
Sub SetPtr(LocalType, ModuleType)
LocalType = ModuleType
End Sub
Since this passes a reference your localtype can be assigned to the a difference moduleType by passing it and the module to the sub.
Just pass the module type you want to assign to it.
Or something like that
Now I think about it more, I'm not sure this would work
-
Apr 27th, 2000, 07:10 AM
#11
Fanatic Member
But it would work with object references!!!
If you uses classes instead of types. you can dim a new object and use it as a reference holder for an already created object rather than create a third object

-
Apr 28th, 2000, 01:35 AM
#12
Thread Starter
Junior Member
i'm still new to vb, how would i go about doing that.
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
|