Declaring object arrays as public

  • Thread starter Thread starter WStoreyII
  • Start date Start date
W

WStoreyII

when ever i try to declare an object array in the declarations area
for instanc,

Dim MyRows() as DataRow
it will let me do this fine

but if i try to add a length to it for example

Dim MyRows(myds.tables("MyTable").rows.count ) as datarow
it will not let me do this it says that

"Constant expression expected"

but it will not let me make it a constant

what do i do?

WStoreyII
 
I'm new to .Net so I hope I'm accurate here.

This here >> myds.tables("MyTable").rows.count << is a variable, it changes
or can change. It could = 10 or it could = 10,000 therefor VB doesn't know
what size you are telling the new array to be. It needs a definite number
like...
Dim MyRows(100) as DataRow

However you could try it this way though...

Dim MyRows() as DataRow
Redim MyRows(myds.tables("MyTable").rows.count)

Again you'll have to check my syntax on that since I'm just getting into
..Net


Ray.
 
* "WStoreyII said:
when ever i try to declare an object array in the declarations area
for instanc,

Dim MyRows() as DataRow
it will let me do this fine

but if i try to add a length to it for example

Dim MyRows(myds.tables("MyTable").rows.count ) as datarow
it will not let me do this it says that

"Constant expression expected"

\\\
Dim MyRows() As DataRow
..
..
..
MyRows = New MyRows(myds.tables("MyTable").Rows.Count - 1) {}
///
 
Back
Top