I don't know vb very well, but I think there might be a problem with the following lines: | Code: |
... position = position + 1 ...
|
I'm guessing after you enter in a name or something, you increment your position by 1.
Then later you go onto adding items into some sort of list display container.
| Code: |
For index = 1 To position lstDisplay.AddItem names(index) + Str$(marks(index)) Next
|
Now what I think is a problem is as follows. Because of the way you've implemented your position, it will always be + 1, everytime you get a new name. Now, I'm not sure, but I'm guessing VB initializes integers to 0. So say you start at 0 and you add 3 people, your count will be 0[first name] pos+1, 1[second name], pos+1, 2[third name], pos+1. At the end of this, position = 3.
Now later, you start to add items, and you index from 1 - position, for this case, it's 3.
That means you are indexing
names(1), names(2), and names(3).. well, names(3) doesn't exist.
You might want to try doing your for from 0 -> pos - 1
Or use an iterator.
Note: IF VB indexes from 1->n and NOT 0->n-1, then you can fix this by incrementing position before you assign the text into the arrays.
-------
I've got spurs that jingle jangle jingle.
As I go riding merrily along.
And they sing, "Oh, ain't you glad you're single?"
And that song ain't so very far from wrong.