我想分配給一個數組的記錄,必須分裂成更多的元素爲搜索條件的原因。例如,如果criteria設置爲First Name,則搜索數組元素0中的匹配關鍵字,因爲這是在當前所選記錄爲Split()之後放置名字的位置。NullReferenceException是未處理的VB.NET
源的搜索格式:
Public Class frmSearch
Dim arrayCurrentRecord(6) As String
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.DialogResult = DialogResult.Cancel
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
'fill array with list box items
Dim arraySearch(frmMain.numberOfRecords) As String
For i = 0 To frmMain.numberOfRecords - 1
arraySearch(i) = frmMain.lstListBox.Items(i)
Next i
If rbtnFirstName.Checked = True Then
For i = 0 To UBound(arraySearch)
arrayCurrentRecord = arraySearch(i).Split(" ")
If InStr(arrayCurrentRecord(0), txtSearch.Text) = True Then
lstSearch.Items.Add(arraySearch(i))
End If
Next i
MsgBox("search complete")
End If
End Sub
End Class