Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multidimensional arrays

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am trying to create a multidimensional array and am recieving a
I am trying to create a multidimensional array and am recieving an error
Object reference not set to an instance of an object. Is my array setup correctly? If I don't use an array I don't recieve errors and all my data prints out on response.writes.

Dim i as integer = -1
Dim row As DataRow
Dim k As Integer = 0
Dim thelist as string
Dim thepropID as String
Dim oldstate as string = " "
Dim proparray( , ) as string
Dim strVDS as string
Dim arraybounds as integer
Dim rowscount as integer = empDS.Tables("properties").Rows.count

For Each row In empDS.Tables("properties").Rows
If empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;propName&quot;) <> oldstate Then
i = i + 1
oldstate = empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;state&quot;)
End if
proparray(i,0) = empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;state&quot;)
proparray(i,1) = empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;propName&quot;) + &quot;|&quot; + empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;propName&quot;)
proparray(i,2) = empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;xscale&quot;) + &quot;|&quot; + empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;xscale&quot;)
proparray(i,3) = empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;yscale&quot;) + &quot;|&quot; + empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;yscale&quot;)
proparray(i,4) = empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;propID&quot;) + &quot;|&quot; + empDS.Tables(&quot;properties&quot;).Rows(k).Item(&quot;propID&quot;)
k = k + 1
Next
 
You must declare the bounds of your array. For example, instead of having:

Dim proparray(,) as string

You could have:

Dim proparray(5, 100) as string

Or:

Dim Dimension1Size as integer = 5
Dim Dimension2Size as integer = 100
Dim proparray(,) as string
Redim proparray(Dimension1Size, Dimension2Size)

HTH! Kevin B.
.Net Programmer [thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top