Vb.net 使用Like函数进行搜索
我正在搜索我的数据网格视图。我的搜索变量从单元格中选取数据,与搜索字符串和报告匹配。这太完美了。Vb.net 使用Like函数进行搜索,vb.net,Vb.net,我正在搜索我的数据网格视图。我的搜索变量从单元格中选取数据,与搜索字符串和报告匹配。这太完美了。 我需要使它的工作,以便如果使用希望搜索说“约翰”,块包含“约翰史密斯”应该匹配。目前我不得不完全使用“约翰·史密斯” 请告诉我怎么做。我的代码如下所示 Do While vrTotalRows > vrLoopCntr vrPickFromGrid = UCase(DataGridView1.Item(0, vrLoopCntr).Value)
我需要使它的工作,以便如果使用希望搜索说“约翰”,块包含“约翰史密斯”应该匹配。目前我不得不完全使用“约翰·史密斯” 请告诉我怎么做。我的代码如下所示
Do While vrTotalRows > vrLoopCntr
vrPickFromGrid = UCase(DataGridView1.Item(0, vrLoopCntr).Value)
If vrPickFromGrid = UCase(txtFind.Text) Then 'Found
DataGridView1.Rows(vrLoopCntr).DefaultCellStyle.BackColor = Color.CornflowerBlue
End If
vrPickFromGridC2 = UCase(DataGridView1.Item(1, vrLoopCntr).Value)
If vrPickFromGridC2 = UCase(txtFind.Text) Then 'Found
DataGridView1.Rows(vrLoopCntr).DefaultCellStyle.BackColor = Color.CornflowerBlue
End If
vrLoopCntr = vrLoopCntr + 1
Loop
使用String.Contains(…)
我建议您使用
变成:
If vrPickFromGrid.Contains(UCase(txtFind.Text)) Then
Ugh-用于代码的样式上写满了vb6。您现在所做的大部分工作都是向后的。您建议如何使其成为vb.net代码?
If vrPickFromGrid.Contains(UCase(txtFind.Text)) Then