• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

arrays in VB


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
kushcu
Asked:
kushcu
1 Solution
 
JH0401Commented:
may we see your declaration???
0
 
tolstoyleoCommented:
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
 
JacamarCommented:
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.

 
JH0401Commented:
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
 
JH0401Commented:
Why do you need a 5 dimensional array???
0
 
tolstoyleoCommented:
um... JH0401... that was the exact same answer i gave?
0
 
JH0401Commented:
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
 
kushcuAuthor Commented:

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now