Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm getting error with this code:

VB
For j = 1 To srchtbl.RowCount


                If srchtbl.Item(1, j).Value = ComboBox1.Text Then
                    irs = (srchtbl.Item(0, j).Value)
                    branchID = (srchtbl.Item(2, j).Value)
                Else

                End If
            Next


i have 29 row and 3 columns in srchtbl.

Error message:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Posted
Updated 14-May-13 21:57pm
v2
Comments
Prasad_Kulkarni 15-May-13 2:43am    
On which line you're getting this error?
Justin Jendrick Nocillado 15-May-13 2:48am    
If srchtbl.Item(1, j).Value = ComboBox1.Text Then <- here
Prasad_Kulkarni 15-May-13 2:54am    
Debug the code line by line and check what are the values you're getting over there.

1 solution

It's okay na. I solved it.

heres the new code

VB
For j = 1 To srchtbl.RowCount


              If srchtbl.Item(1, j - 1).Value = ComboBox1.Text Then
                  irs = (srchtbl.Item(0, j - 1).Value)
                  branchID = (srchtbl.Item(2, j - 1).Value)
              Else

              End If
          Next
 
Share this answer
 
Comments
Prasad_Kulkarni 15-May-13 3:13am    
Good work!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900