Arrays please help me

G

Guest

Hi all
I have two arrays .
array1 contains 10 elements
array2 contains 6 elements
I need to assign the left over 4 elements of array1 into new array .
Can anyone give me a peice of code ,how to achieve this?
ITs really urgent please help me
thanks in adv
 
M

Mike Lowery

aka said:
Hi all
I have two arrays .
array1 contains 10 elements
array2 contains 6 elements
I need to assign the left over 4 elements of array1 into new array .
Can anyone give me a peice of code ,how to achieve this?
ITs really urgent please help me
thanks in adv

Assuming your arrays start at base zero:

Dim array3(4)
for i=0 to 3
array3(i) = array1(i + 6)
next i
 
G

Guest

Another way may be to use List instead of array...
Dim OldList As New List(Of String)
Dim NewList As New List(Of String)

' If OldList contains 10 elements, this will get the 6th thru 10th from
OldList
' and add them to NewList
NewList.AddRange(OldList.GetRange(6, 4))
 

Ask a Question

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.

Ask a Question

Top