我正在使用文本框在访问数据库中搜索,然后在组合框中显示匹配项,它工作正常,但是当用户输入不匹配的条目时会产生错误,
这是我的代码:
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
Try
ComboBox3.DataSource = Me.MyDataset.Items.Select("ItemName like '%" & TextBox9.Text & "%'")
ComboBox3.Update()
If ComboBox3.Items.Count <> 0 Then
ComboBox3.DroppedDown = True
Me.Cursor = Cursors.Default
Cursor.Show()
Else
If ComboBox3.DroppedDown = True Then
ComboBox3.DroppedDown = False
End If
End If
If TextBox9.Text = "" Then
ComboBox3.DroppedDown = False
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
End Try
End Sub
当用户输入错误或不匹配时,会出现此错误:invalidargument=value of '0' is not valid for 'index'。参数名称索引 vb.net
问题是如何处理这个错误