|
-
October 31st, 2002, 05:18 PM
#1
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
-
October 31st, 2002, 05:49 PM
#2
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
-
October 31st, 2002, 09:23 PM
#3
Declare it in a module as
Public gnArray(0) as integer
In your form
Redim gnArray(100)
or
Redim Preserve gnArray(200)
-
November 1st, 2002, 06:33 AM
#4
huh? What are you talking about? I do that all the time and have no problem.
phinds
vs2008, 3.5SP1 Version 9.0.21022.8 RTM
-
November 2nd, 2002, 08:07 PM
#5
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
-
November 3rd, 2002, 04:20 PM
#6
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
-
November 3rd, 2002, 05:22 PM
#7
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
-
November 3rd, 2002, 05:34 PM
#8
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
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
|