I have two questions
1. I am using a regex to search a VB.NET listbox items, the regex expression will pick up all items but i would like it only to find the exact match.
Here is the code iam using:
Code: Select all
Dim iq As Integer
For iq = 0 To ListBox1.Items.Count - 1
Dim RO As String = (ListBox1.Items(iq).ToString)
Dim regex As Regex = New Regex("sum")
Dim input As String = iq
If InStr(RO, regex.ToString) Then
'do something
nextMy second question is about assigning a variable to the expression (text to search for).
can i chnage the code to:
Code: Select all
Dim iq As Integer
For iq = 0 To ListBox1.Items.Count - 1
Dim RO As String = (ListBox1.Items(iq).ToString)
Dim str1 as string = "sum"
Dim regex As Regex = New Regex(str1)
Dim input As String = iq
If InStr(RO, regex.ToString) Then
'do something
nextThanks