I have one doubt in VB. If possible, can u explain me please
I have a string = "googlemailsearch"
I want to check whether the characters "mail" is available in the above string !
The characters "mail" would be in any place. Can be in the begining or at the last ....

string ?
Attila Fogel
InStr is not a method of the string classes. It's a function!
A better solution would be to use the native .Contains method.
Dim MyString As String = "googlemailsearch"
If MyString.Contains("mail") Then
' Do Something
End If
Chris Honcoop
Yes I think 'Contains' would do the trick. Another way to do it would be to use 'IndexOf' - apart from telling you whether the substring is present, IndexOf would also tell you the location of the substring within the main string.
Module Module1
Sub Main()
Dim str As String = "googlemailsearch"
Console.WriteLine(str.IndexOf("mail")) 'Prints 6
Console.WriteLine(str.IndexOf("absent")) 'Prints -1
End Sub
End Module
Hope this helps.
Shyam
Rattlerr
Hello Shah !
Thanks for your immd reply.
The following code helps good.
Private Sub Form_Load()
If InStr(1, "googlemailsearch", "mail") Then
MsgBox ("Found It")
End If
End Sub
matman13
Use InStr method of the string classs
Dim str As String = "googlemailsearch"If
InStr(str, "mail", CompareMethod.Text) ThenMsgBox(
"Found It") End IfNeal Sidhwaney
SJWhiteley,
I think your code works only for vb.net !
Anyway, my thanks for ur efforts.