is there is easier way to copy array values?
dim Arry() as string
redim arry(3)
arry(1)="Jim"
arry(2)="Bob"
arry(3)="Harry"
Dim NewArry() as string
redim newarry(ubound(arry))
for a= 0 to ubound(newarry)
newarry(a)=arry(a)
next a
Printable View
is there is easier way to copy array values?
dim Arry() as string
redim arry(3)
arry(1)="Jim"
arry(2)="Bob"
arry(3)="Harry"
Dim NewArry() as string
redim newarry(ubound(arry))
for a= 0 to ubound(newarry)
newarry(a)=arry(a)
next a
first of all if you create an array like you do
you create an array of 3 strings: arry(0), arry(1), arry(2) and arry(3)VB Code:
dim Arry() as string redim arry(3)
if you want to create an arry wit only indexes 1 to 3
use this redim arry(1 to 3) or do it your way but add on on top of your module:
to copy an array just try this:VB Code:
option base 1
it works like a charm:VB Code:
NewArry = Arry
So:
VB Code:
Dim Arry() As String ReDim Arry(3) Arry(1) = "Jim" Arry(2) = "Bob" Arry(3) = "Harry" Dim NewArry() As String ReDim NewArry(UBound(Arry)) NewArry = Arry
should I delete this before anyone sees it?
thanks
- Kurt
No. Leave it here, but edit your first post and change the title to include the word "*Solved*"Quote:
Originally posted by kurtsimons
should I delete this before anyone sees it?
I figured out why it didn't work when I first tried this... I didn't redim the array.