Ok I am having a slight problem. For my class I am supposed to create a program that allows a user to enter part of an author's name, part of the title of the book, or part of the ISBN number and shows the title of matches or partial matches in a listbox. It also allows the user to click the title in the listbox and it displays the author's name, title of the book, ISBN number, price, and section in respective textboxes. My problem I am encountering is in my search structure.
CODE
Private Sub btnTitle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTitle.Click
Dim strSearchString As String
Dim blnFound As Boolean
Dim strATitle As String
'Initialize boolean variable to false
blnFound = False
'Validate input in title textbox
If txtTitle.Text = "" Then
txtTitle.Text = InputBox("Please enter a title.", "Title required")
Exit Sub
End If
'Get input value
strSearchString = txtTitle.Text
'Search array and display all matches
For Each strATitle In strTitle
If InStr(UCase(strATitle), UCase(strSearchString)) > 0 Then
lstBooks.Items.Add(strATitle)
blnFound = True
End If
Next
'Handle No Match situation
If Not blnFound Then
MsgBox("No match found. Please try again.", MsgBoxStyle.Exclamation, "No match found")
txtTitle.Text = ""
txtTitle.Focus()
End If
End Sub
My arrays all load properly and work fine but when I hit the search button I get a System.NullReferenceException error and the additional information it gives me is that the "Object reference not set to instance of an object." I have code identical to this in another search program, using different variable names, and it works just fine. Anyone have any clues?
This post has been edited by Panther85: 19 Nov, 2006 - 01:38 PM