OK, I am sure this is a really basic problem, but for some reason, the answer is eluding me...
Here is the background:
-I have a list of ranks, ex. Basic, Basic, Basic, Leader, Basic, Basic, Basic, Leader, General, Basic. They are stored in an array such as _arrMemberList(1).Rank.
-I want to add one of each to a Combo Box. Here is the code I have written
1. Private Sub DisplayGuildRanks(ByVal _arrMemList() As GuildMember)
2. Dim exists As Boolean = False
3. For _intMember As Int32 = 1 To _arrMemList.GetUpperBound(0)
4. For _intAddedRank As Int32 = 1 To cmbRankList.Items.Count
5. If cmbRankList.Items(_intAddedRank) = _arrMemList(_intMember).Rank Then
6. exists = True
7. End If
8. Next
9. If exists = False Then
10. cmbRankList.Items.Add(_arrMemList(_intMember).Rank)
11. End If
12. Next
13. End Sub
The cmbRankList has no items in it previous to this, and it keeps crashing on line 5. With the error:
Here is the background:
-I have a list of ranks, ex. Basic, Basic, Basic, Leader, Basic, Basic, Basic, Leader, General, Basic. They are stored in an array such as _arrMemberList(1).Rank.
-I want to add one of each to a Combo Box. Here is the code I have written
1. Private Sub DisplayGuildRanks(ByVal _arrMemList() As GuildMember)
2. Dim exists As Boolean = False
3. For _intMember As Int32 = 1 To _arrMemList.GetUpperBound(0)
4. For _intAddedRank As Int32 = 1 To cmbRankList.Items.Count
5. If cmbRankList.Items(_intAddedRank) = _arrMemList(_intMember).Rank Then
6. exists = True
7. End If
8. Next
9. If exists = False Then
10. cmbRankList.Items.Add(_arrMemList(_intMember).Rank)
11. End If
12. Next
13. End Sub
The cmbRankList has no items in it previous to this, and it keeps crashing on line 5. With the error:
I was getting frusturated so I decided to call it a night.An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.