?
Solved

arrays in VB

Posted on 2003-03-17
8
Medium Priority
?
276 Views
Last Modified: 2010-05-03

Hi,

I'm trying to declare a 5-dimensional array in VB for some assignment. But as soon as I do that, VB gives me "out of memory" error. Is there any way to get around this problem?

Thanks.
0
Comment
Question by:kushcu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:JH0401
ID: 8154480
may we see your declaration???
0
 
LVL 1

Accepted Solution

by:
tolstoyleo earned 700 total points
ID: 8154525
try this:  this is a 5 dimensional array in vb


Private Sub Form_Load()

Dim aFive(0, 0, 0, 0, 0) As Variant
aFive(0, 0, 0, 0, 0) = "test"
MsgBox (aFive(0, 0, 0, 0, 0))

End Sub

0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8154549
Well, I know that vb can handle 5 dimensional arrays.  I Just put one together that will be 5 dimensions with 2 elements in each.  Looks like this.

Private Sub Command1_Click()
Dim array1(1 To 2, 1 To 2, 1 To 2, 1 To 2, 1 To 2) As Single

For ini = 1 To 2
    For inj = 1 To 2
        For i = 1 To 2
            For ii = 1 To 2
                For iii = 1 To 2
                    array1(ini, inj, i, ii, iii) = iii
                    Text2.Text = Text2.Text & array1(ini, inj, i, ii, iii)
                Next iii
            Next ii
        Next i
    Next inj
Next ini
End Sub

You should post what your code looks like so we can take a look.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:JH0401
ID: 8154592
What are you trying to store in this array???

Try this

Dim aFive(1,1,1,1,1) as variant
aFive(1,1,1,1,1) = "test"
msgbox aFive(1,1,1,1,1)

This will only allow for 1 value in each parameter of the array!!!
0
 
LVL 1

Expert Comment

by:JH0401
ID: 8154601
Why do you need a 5 dimensional array???
0
 
LVL 1

Expert Comment

by:tolstoyleo
ID: 8154648
um... JH0401... that was the exact same answer i gave?
0
 
LVL 1

Expert Comment

by:JH0401
ID: 8154684
i know -- i was just making sure that kushcu knew that this would allow for only 1 value in each parameter.  I was wondering why a 5 dimensional array was needed????
0
 

Author Comment

by:kushcu
ID: 8155851

sorry guys. have the problem sorted out. the code had a bug somewhere else.

since it is the first answer with some code in it, I'll give the points to tolstoy.

thanks for your time.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question