vabatta
Member
- Joined
- Jan 15, 2012
- Messages
- 9
- Programming Experience
- Beginner
Hi all,
I'm collecting in an array the splitted text of a textbox in order to search in a bimensional array for matching in the name, but I got the error "NullReferenceException" at the red line.
Now, I looked the code multiple times, but I didn't find the error... Who can help me?
I'm collecting in an array the splitted text of a textbox in order to search in a bimensional array for matching in the name, but I got the error "NullReferenceException" at the red line.
Now, I looked the code multiple times, but I didn't find the error... Who can help me?
VB.NET:
[COLOR=#0000cd]Dim[/COLOR] info(0 [COLOR=#0000cd]To[/COLOR] 0, 0 [COLOR=#0000cd]To[/COLOR] 5) [COLOR=#339900]'this is array is already filled by a sub[/COLOR]
[COLOR=#0000cd]Dim[/COLOR] temp(0 [COLOR=#0000cd]To[/COLOR] 0) [COLOR=#0000cd]As String[/COLOR] [COLOR=#339900]'array temp[/COLOR]
[COLOR=#0000cd]Dim[/COLOR] temp2() [COLOR=#0000cd]As String[/COLOR] = Split(txtSearch.Text.ToLower, " ") [COLOR=#339900]'the splitted text from textbox, like "test 12"
[/COLOR][COLOR=#0000cd]For[/COLOR] s = 0 [COLOR=#0000cd]To[/COLOR] UBound(temp2, 1) [COLOR=#339900]'count for each split[/COLOR]
[COLOR=#0000cd]For[/COLOR] i = 0 [COLOR=#0000cd]To[/COLOR] UBound(info, 1) [COLOR=#339900]'count for each info name[/COLOR]
[COLOR=#0000cd]If[/COLOR] [COLOR=#ff0000]info(i, 1).ToLower.Contains(temp2(s))[/COLOR] [COLOR=#0000cd]Then[/COLOR] [COLOR=#339900]'if splitted text contains info name[/COLOR]
[COLOR=#0000cd]ReDim Preserve[/COLOR] temp(0 [COLOR=#0000cd]To[/COLOR] UBound(temp) + 1) [COLOR=#339900]'redim the array temp + 1[/COLOR]
temp(UBound(temp)) = i [COLOR=#339900]'save the value[/COLOR]
[COLOR=#0000cd]End If[/COLOR]
[COLOR=#0000cd]Next[/COLOR]
[COLOR=#0000cd]Next[/COLOR]
Last edited: