Is there a contain's method?
I know there's a method contain(), it looks like this:
Dim arr() as string = {"apple","banana","orange"}
For each fruit in arr
If fruit.contains("app") The开发者_如何转开发n
Return True
End If
Next
It will return true because "apple" contains letter "a". This is not what I want. I want it to return true only when "apple" contains the whole word "app". Is there any method or function to do this?
"apple" does in fact contain the whole word "app", so Contains() is still probably your best bet.
From MSDN:
String.Contains Method Returns a value indicating whether the specified String object occurs within this string.
Here is the link to it with samples.
http://msdn.microsoft.com/en-us/library/dy85x1sa.aspx
You can use:
If fruit.IndexOf("app") <> -1 Then
Return True
End If
精彩评论