BlueOysterCult
Regular
- Joined
- Oct 3, 2003
- Messages
- 84
Hello again my fellow Net forum users
I am wrestling with this Find Function and button. I am getting a Null Refernce error - I have tried every combination of things to no avail. I should point out that in the Autos tab I am getting a value (the artist I put in the FindBox.text) but it is red(?)
Function:
the button:
Thanks
Rob
I am wrestling with this Find Function and button. I am getting a Null Refernce error - I have tried every combination of things to no avail. I should point out that in the Autos tab I am getting a value (the artist I put in the FindBox.text) but it is red(?)
Function:
Code:
Public Function FindArtist(ByVal strArtistToFind As String) As Integer
Dim i As New Integer
'Dim ArtistIndex As Integer
'loop through the array
For i = 0 To CdArray.GetUpperBound(0)
If CdArray(i).strArtist = strArtistToFind Then
'we found the artist, return this index
Return i
End If
Next
'once this code is executed we know we didn't find an artist
Return -1
End Function
the button:
Code:
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim index As Integer = FindArtist(txtFindBox.Text)
If index <> -1 Then
txtArtist.Text = CdArray(index).strArtist
txtTitle.Text = CdArray(index).strTitle
txtYear.Text = CdArray(index).strYear
txtCategory.Text = CdArray(index).strCategory
Else
MessageBox.Show("Artist not Found")
End If
End Sub
Rob