WPCap
asked on
VB.NET Insert data into array.
Hi there, I have a string of names:
John,Borris,James,Chris
Now I need to insert those names into array.
Then after I need to create a loop that will search for those names in other string.
If any of those names, in any format (lowercase, uppercase) are matched then do stuff.
Thank you.
John,Borris,James,Chris
Now I need to insert those names into array.
Then after I need to create a loop that will search for those names in other string.
If any of those names, in any format (lowercase, uppercase) are matched then do stuff.
Thank you.
ASKER
Something seems to be wrong with the last statement. I put some random string "tgds" and it found 3 matches however there aren't any.
It should match the name precisely. the whole name.
if string contains afoshaofiahaosifhaJOHHNYfa sfh13afnfs o and in the array is name JOHHNY or jOhHny then it should give one positive match.
It should match the name precisely. the whole name.
if string contains afoshaofiahaosifhaJOHHNYfa
ASKER
I wasn't too clear in the last message but I hope you got the point, if not then...
The data in TESTSTRING is changing every second or so. now the loop should constantly look if in TESTSTRING there is a positive match to anything that is in the array.
What I'm doing is: I have an application that captures incoming packet on specific IP.
Now when the packet arrives, for each statement should check if that packet contains any of the names in the array.
The data in TESTSTRING is changing every second or so. now the loop should constantly look if in TESTSTRING there is a positive match to anything that is in the array.
What I'm doing is: I have an application that captures incoming packet on specific IP.
Now when the packet arrives, for each statement should check if that packet contains any of the names in the array.
ASKER
I think in this case I'd need a code that would search through the packet as soon as it arrives. I will put it in onPacket event.
ASKER
I used textbox1.text instead of targetstr
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
For i As Integer = 0 To bannedArr.Length - 1
If TextBox2.Text.ToString.Ind exOf(banne dArr(i), StringComparison.Invariant CultureIgn oreCase) >= 0 Then
MessageBox.Show("match")
End If
Next
End Sub
For i As Integer = 0 To bannedArr.Length - 1
If TextBox2.Text.ToString.Ind
MessageBox.Show("match")
End If
Next
End Sub
ASKER
yes, exactly.
ASKER
I typed !*(@$&SF)!$ it gave me 3 matches... I typed 9(!J(!#!JFAS , same , 3 matches.
ASKER
I used this:
and typed into the textbox something like !(#&@$NJASF and it gave me 3 matches, all of them were blank.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
For i As Integer = 0 To bannedArr.Length - 1
If TextBox2.Text.ToString.IndexOf(bannedArr(i), StringComparison.InvariantCultureIgnoreCase) >= 0 Then
MessageBox.Show(bannedArr(i))
End If
Next
End Sub
and typed into the textbox something like !(#&@$NJASF and it gave me 3 matches, all of them were blank.
ASKER
I tried to put a match into the textbox and it gave me the matched name and also 3 empty messagebox responses.
What's in bannedArr?
http://msdn.microsoft.com/en-us/library/k8b1470s.aspx
I would modify the code as below
If value is String.Empty, the return value is 0
http://msdn.microsoft.com/en-us/library/k8b1470s.aspx
I would modify the code as below
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
For i As Integer = 0 To bannedArr.Length - 1
If Not String.IsNullOrWhiteSpace(bannedArr(i)) Then
If TextBox2.Text.ToString.IndexOf(bannedArr(i), StringComparison.InvariantCultureIgnoreCase) >= 0 Then
MessageBox.Show(bannedArr(i))
End If
End If
Next
End Sub
ASKER
Great job, man. Thanks.
Perhaps you'd want to look at my other question here:
https://www.experts-exchange.com/questions/27477687/VB-NET-HEX-to-STRING.html
Perhaps you'd want to look at my other question here:
https://www.experts-exchange.com/questions/27477687/VB-NET-HEX-to-STRING.html
ASKER
Before there was an option to choose assisted solution... Now it's gone I guess. It just didn't seem fair to me to accept your solution, CodeCrusier since kaufmed did most of the job, sorry.
You can "Request Attention" to have the question reopened if you'd like to select multiple comments as the answer = )
Open in new window
Open in new window
Open in new window