|
-
Nov 1st, 1999, 04:59 AM
#1
Thread Starter
New Member
I might just be dumb, but is there any way to Dim an array using a variable? IE. Dim Array(1 To UBoud, 1 To 3) As String
-
Nov 1st, 1999, 05:59 AM
#2
No, but you can Redim it if you need to.
------------------
Marty
-
Nov 1st, 1999, 06:00 AM
#3
New Member
I wrote a program where I wanted a varying number of elements without having to keep updating code. I did something like this:
FileCount = FileCount + 1
ReDim Preserve NumFiles(FileCount)
Then I added my new element:
NumFiles(FileCount) = file$
This may be what you want to do.
-
Nov 1st, 1999, 09:54 AM
#4
Thread Starter
New Member
Hey, thanks guys. :-)
Now what are the odds that I can keep this variable that I'm constantly ReDim-ing Global the whole time?
-
Nov 1st, 1999, 10:32 AM
#5
Addicted Member
Declare it as Static!
Phil
-
Nov 1st, 1999, 11:04 AM
#6
Thread Starter
New Member
Thanks, Phil. :-)
Sorry for askin' all the dumb questions, I haven't had VB for long and I'm still trying to do most of my coding QB style. Most of it works, though.
-
Nov 1st, 1999, 01:03 PM
#7
Lively Member
hello friends
You can declare an array like this
dim sarray(ubound) as string
u need to declare "ubound" as constant
Thanx Manish
-
Nov 1st, 1999, 01:26 PM
#8
Thread Starter
New Member
Another question for you guys 'cause I'm dumb... Well, OK. It's the same question again.
The Static thing isn't working. Not the way I want it to. From what I've read now that I looked it up, Static claims that it still only works in one Sub but that it endures repeated calls. I need to be able to repeatedly ReDim the array, but I need it to be legitimately Global so that I can share it with many different Subs. Is Static really right and I'm just not doing it right or is there some other way?
-
Nov 1st, 1999, 01:33 PM
#9
Lively Member
hi
what i understand is u want a constant value and want to redim an array on the basis of the constant value. Am i right?? u can use constant declare it in a form or in a BAS according to yr need and u can use it. as per the scope.
Thanx Manish
-
Nov 2nd, 1999, 02:48 AM
#10
New Member
Hey, I just read your recent question. I had the Global MyArray() as string in the declaration and set the array to zero before the loop by putting ReDim MyArray(0) before the loop began. Also, you can declare the variable you are resetting the MyArray length to as Global as well. Well, I hope that this will shed more light on your question. Sorry, I should have put this stuff in there too. Let me know if I can be of more help.
[email protected]
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
|