-
dynamic array
In a VB form globally
you can do this
Dim A(8) as Integer
Bt you cant do
Dim A() as integer
coming up with ambigious..
How woudl you declare a dynamic array accessible throughtout the form by any Function or Sub that you can redim here and there
Thanks
-
Private damnA() as Long
...
..
Sub F1
i=100
ReDim damnA(1 to i)
End sub
Sub F1
i=200
ReDim damnA(1 to i)
End sub
-
Declare it in a module as
Public gnArray(0) as integer
In your form
Redim gnArray(100)
or
Redim Preserve gnArray(200)
-
huh? What are you talking about? I do that all the time and have no problem.
-
Quote:
Dim A() as integer
To REDIM an array anywhere within a Form declare it in the General Declarations section of the form.
'
If you wish to access the array from outside the form you can declare it Public or stuff it in a module.
The sample below works just fine
Code:
Option Explicit
Dim A() As Integer
Private Sub Command1_Click()
ReDim A(100)
End Sub
-
Vb does not like dim outside of a procedure unless it is not going to be redimmed.
I think it has to be Private Dim A() as integer outside of the procedures and inside you can then reDim...
Thanks anyway
-
Saeed,
I have to disagree with you. I've always used the same syntax to declare a dynamic array in a form. In fact, I've just tested the code below:
Code:
Dim A() As Integer
Private Sub Form_Load()
ReDim A(10)
End Sub
and it worked as expected. Maybe our cases are not the same. Anyhow, what was the error that you received?
-Cool Bizs
-
I hate It.
VB just poured a bucket of ice water on my head...
It used to happen ..Now its not happening.....
mmmmm
surely there is somethhing wrong with Windows or PC or VB...NOT ME ;)
I used to get a Message that I cant do what I just did , but now it seems to work
without any problem after putting it back to what you suggested.
Thanks for your reply and I am glad you disagreed with me;)