I have the following code to collect data from a dataset. I put in the msgbox so I can see whats going on.
Dim
cntr As Integer = 0
Dim cnt As Integer = CostItemsBindingSource.Count
MsgBox(
"cnt= " & cnt)
ReDim CostCodeArray(cnt)
ReDim CostNameArray(cnt)
Dim ciRow As BuildersEstimatorDatabaseDataSet.CostItemsRow
For Each ciRow In BuildersEstimatorDatabaseDataSet.CostItems.Rows
CostCodeArray(cntr) = ciRow.CostCode
CostNameArray(cntr) = ciRow.CostName
MsgBox(
"cntr= " & cntr & vbLf & "CostCode(" & cntr & ")= " & CostCodeArray(cntr))
cntr = cntr + 1
Next
Dim i As Integer
For i = 0 To (CostCodeArray.Count - 1)
MsgBox(
"i= " & i & vbLf & "Cost Code= " & CostCodeArray(i))
Next
The problem is that I am getting one more item in my array that is blank than there are rows of data in my dataset. What am I doing wrong here?
Thanks