G
Guest
Hey all,
How do I add an element to an already populated array?
dim myary() as string
thanks,
rodchar
How do I add an element to an already populated array?
dim myary() as string
thanks,
rodchar
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Imran Koradia said:Dim myarray() As Integer = {1, 2}
ReDim Preserve myarray(2)
myarray(2) = 3
Don't forget the preserve word or else all the elements will be lost from
the array. Also, you would be better off using an ArrayList if you are
going
to be adding elements frequently since Redim Preserve is expensive
performance-wise (especially with larger arrays).
hope that helps..
Imran.
Imran Koradia said:Dim myarray() As Integer = {1, 2}
ReDim Preserve myarray(2)
myarray(2) = 3
Don't forget the preserve word or else all the elements will be lost from
the array. Also, you would be better off using an ArrayList if you are going
to be adding elements frequently since Redim Preserve is expensive
performance-wise (especially with larger arrays).
hope that helps..
Imran.
rodchar said:how do you clear an entire array. And if you clear an array would you still
have to redim it if you filling it up with more than it had prior to clear?
thanks,
rodchar
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.