|
-
Aug 13th, 2001, 06:52 PM
#1
Thread Starter
Stuck in the 80s
Arrays?
I don't want to sound like a dumbass, but is there a way to use arrays in Visual Basic, such as you can in Perl?
I want to be able to have a list of error messages and call them by like Error(10) or whatever. Is there something similiar to this? If so, can someone tell me how to declare it and use it?
Thanks in advance.
-
Aug 13th, 2001, 07:20 PM
#2
Fanatic Member
yep
VB Code:
Dim E(1 to 10) As String
E(1) = "Very Bad Error"
E(2) = "Even Worse Error"
E(3) = "Blue Screen of Death!"
MsgBox E(3)
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Aug 13th, 2001, 07:28 PM
#3
New Member
arrays with variables
hey, is it possible to declare an array with one dimension being a variable? Life say I want to save memory so i open a file as #0 and then
Dim i as integer
do while not EOF(0)
i = i + 1
loop
Can I use i in declaring an array? As in
Dim arrfoo(0 to 0, 0 to i) as string
Thanks for your help
Steve Gazzo
"Hack for fun, program for profit."
-
Aug 13th, 2001, 07:38 PM
#4
Fanatic Member
i don't think VB lets you dim an array with a variable the first time, what you have to do is declare it dynamically
VB Code:
Dim E() As String
i = 5
ReDim E(1 to i, 1 to i) As String
also keep in mind (this is a problem i ran into a while back) that when declaring arrays dynamically using preserve, you can only change the last dimension
so...
ReDim E(1 to i, 1 to i) As Integer
is legal
but after that...
ReDim Preserve(1 to i, 1 to i + 1) As Integer
is not, so you can only do
ReDim Preserve(1 to i, 1 to i + 1) As Integer
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
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
|