I just recently started getting an index out of bounds error on one of my arrays at runtime. I was not having this issue previously. It only seems to happen when several items are added to a listbox. Here is my declaration and code. Thanks for any help resolving this issue.
The actual error message is:Code:Dim ClientActiveMedProbs(frmmain.lstActiveMedProbs.Items.Count) As String 'store all active medical problem information in an array & build a string For i As Integer = 0 To frmmain.lstActiveMedProbs.Items.Count - 1 ClientActiveMedProbs(i) = frmmain.lstActiveMedProbs.Items.Item(i).ToString Next If frmmain.lstActiveMedProbs.Items.Count = 0 Then ActiveMedProbsResult = "" Else ActiveMedProbsResult = String.Join(", ", ClientActiveMedProbs) ActiveMedProbsResult = Left(ActiveMedProbsResult, Len(ActiveMedProbsResult) - 2) End If
Index was outside the bounds of the array.




Reply With Quote