|
-
Nov 11th, 2002, 09:25 AM
#1
Thread Starter
Fanatic Member
Copy an array *SOLVED*
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
Last edited by kurtsimons; Nov 11th, 2002 at 06:22 PM.
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Nov 11th, 2002, 09:45 AM
#2
Fanatic Member
first of all if you create an array like you do
VB Code:
dim Arry() as string
redim arry(3)
you create an array of 3 strings: arry(0), arry(1), arry(2) and 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:
it works like a charm:
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
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
-
Nov 11th, 2002, 10:02 AM
#3
Thread Starter
Fanatic Member
should I delete this before anyone sees it?
thanks
- Kurt
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Nov 11th, 2002, 10:54 AM
#4
Frenzied Member
Originally posted by kurtsimons
should I delete this before anyone sees it?
No. Leave it here, but edit your first post and change the title to include the word "*Solved*"
-
Nov 11th, 2002, 06:23 PM
#5
Thread Starter
Fanatic Member
I figured out why it didn't work when I first tried this... I didn't redim the array.
Kurt Simons
[I know I'm a hack but my clients don't!]
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
|