Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 707
  • Last Modified:

Anything like vector in VB?

High,

just want to ask how I can create a dynamic array (or something like this) that can dynamically expand its size?

Would you please provide some sample code to explain ?


Thanks!


cyyam
0
cyyam
Asked:
cyyam
1 Solution
 
rengaraajCommented:
redim preserve x(10) as string
0
 
xThorxCommented:
dim VECT() as string
dim VECTNUM() as long
dim VECTTEST() as long

redim VECT(10)
redim VECTNUM(10)
redim VECTTEST(5,10)
....

redim preserve VECT(15) 'add 5 more columns
redim preserve VECTNUM(20) 'add 10 more columns
redim preserve VECTTEST(5,15) 'add 5 more columns

BUT redim preserve VECTTEST(10,10) won't work cause you cannot change the first value of an array but only the last one.

Hope this help.
0
 
cyyamAuthor Commented:
Thanks both of you !

But I think xThorx has given a more detailed answer...

But I still need how to manipulate it, may I ask for your help also?

1. Can I have VECT() to be incremented dynamically without an exact size, just like vector.add() ?

2. If I have declared VECT(10) but I just fill 3 of them, then how can I do my manipulation referring to 3 but not of 10. Will the VECT() size be just 3 but not 10?

And also for delete , insert ...


Thanks a lot!

cyyam
0
 
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept xThorx's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now