|
-
May 27th, 2002, 05:45 PM
#1
Addicted Member
Hey, no probs.
just looking back at that code sample i wrote last night and it's not the best, basically the logic would be as follows:
1) User clicks next
2) you check if you can increment currentRow (by comparing it to faultsDS.Tables("faults").Rows.Count)
3) you display the details for the row at currentRow
translated to code (not that this is off the top of my head)
Code:
'See if we can increment the currentRow variable
if currentRow < faultsDS.Tables("faults").Rows.Count - 1 then
'Note that the Rows collection is indexed from 0 to Count - 1
'ok, we can increment the currentRow variable as we are not
'at the end of the Rows collection yet
currentRow += 1
else
'Set current row to the last row
currentRow = faultsDS.Tables("faults").Rows.Count - 1
end if
'Now we know currentRow is good and ready to go go go!
faultsRow = faultsDS.Tables("faults").Rows(currentRow)
'Add the code here to populate your form with the data
'from the current row, ie faultsRow
I think this is better code. Similar logic could be implemented for a click of the "Previous" button.
Now, because Rows is a collection, as i said above, it is indexed from 0 to Count - 1, meaning you can only pass values of "x" between 0 and Count - 1 when you go Rows(x). For example if there were 10 rows (Count = 10, so valid indexes are between 0 and 9) and you went Rows(10), Rows(11), Rows(12) etc etc you would get an error - ie your program would crash.
Hopw this helps,
funky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|