Jun 17th, 2001, 05:09 AM
#1
Thread Starter
Fanatic Member
Please, Help! I'm trying something...
Hi!
I have a problem!
This file has a simple project that calls an A string.
The string is declared like this: Private A() as String.
When I want to use it I do:
ReDim A(1)
A(1) = "Arie"
Print A(1)
Goes well! But then, when I try this:
ReDim A(2)
A(2) = "Ball"
And Then...
Print A(1)
Print A(2)
The Value of A(1) is gone!!!
What's wrong?!?
Tell me,
Please,
Arie.
Attached Files
Jun 17th, 2001, 07:04 AM
#2
PowerPoster
Use "Redim Preserve .." and it will work *hehehe*
Jun 18th, 2001, 02:09 AM
#3
Thread Starter
Fanatic Member
Ok, that works, but now...
I have another problem!
I had other variables like:
Code:
Type PL
X as Integer
Y as Integer
.
.
.
End type
Public Player As PL
Now the Player.X is gone. why?
All the other are OK.
Did I do something with the Preserve?
How do I use it? Where should I put it?
Help, Fox!
Arie.
Jun 18th, 2001, 04:26 AM
#4
PowerPoster
The Preserve tells ReDim to keep the values in the array youre modifying. It only works for the last dimension of the array, meaning:
Code:
Dim Temp()
ReDim Temp(10) 'Create empty 1D array
ReDim Preserve Temp(20) 'Change size of last dimension
ReDim Temp(10, 10) 'Create empty 2D array
ReDim Preserve Temp(10, 20) 'Change size of last dimension
ReDim Preserve Temp(20, 20) 'Change size of more dimensions - won't work
Erase Temp 'Release memory
About your type: Should work, the errer must be somewhere else..
Jun 18th, 2001, 07:50 AM
#5
Thread Starter
Fanatic Member
Ok... but,...
how this is related with my Type ?
Why my Type values are gone?
All worked until I put this Preserve thing...
What's wrong?
Arie.
Jun 18th, 2001, 08:06 AM
#6
PowerPoster
What do you mean'its gone' ?
If it's not in the properties you may have done a mistake somewhere.. try compiling it.
Jun 21st, 2001, 02:43 PM
#7
Thread Starter
Fanatic Member
Oh, wait... It works!
Thank you very much, Fox!
You were very helpful. Thanx!!!
Arie.
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