-
September 24th, 2003, 12:29 PM
#1
Alternative to dynamic variant arrays?
The answer to this question may be really easy, but my brain is turning to mush with the learning curve moving to .NET.
.
We are moving a vb6 COM dll to vb.net. There is a LARGE amount of dynamic, compund arrays declared as follows in vb6:
.
dim aMyArray() as Variant
then later in the code it is changed as follows:
REDIM aMyArray(x,12)
with x being the number of records returned in a given table query. The 12 represents KNOWN (but mixed) datatypes ie... string, date, etc...
Q. Can each sub element (0-11) be initialized to their respective datatypes? If so, where would they be initialized and how?
.
Thanks
Paul
Paul
-
September 24th, 2003, 01:24 PM
#2
No, they have to be Dim'ed the same, so the best you can do is Dim them as Object.
-
September 25th, 2003, 01:40 PM
#3
Can't you use a structure? That way each dimension represents a different variable type.
Code:
Structure WordsNumbers
Dim word as string
Dim number as integer
end structure
Then you can dimension an array as that type
Code:
dim array(10) as WordsNumbers
That way you can call array(1).word and put a string in it and
array(1).number and put a integer in it etc.
Another example
Code:
Structure People
Dim age as double
Dim name as string
Dim lastname as string
end structure
Code:
dim Person(10) as People
Code:
Person(1).age = 30
Person(1).name = "John"
Person(1).lastname = "Doe"
Last edited by Adovid; September 25th, 2003 at 02:06 PM.
-
September 25th, 2003, 02:08 PM
#4
I'll try that and let you know.
Thanks
Paul
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
|