如何使用vb6检查text1是否包含text2?
Dim text1 as string
Dim text2 as string
text1 = "hello world I am Anas"
text2 = "Anas"
if (check if text2 is in text1) 'the result should be true or false
如何使用vb6检查text1是否包含text2?
Dim text1 as string
Dim text2 as string
text1 = "hello world I am Anas"
text2 = "Anas"
if (check if text2 is in text1) 'the result should be true or false
InStr
函数:Dim position As Integer
position = InStr(1, stringToSearch, stringToFind)
If position > 0 Then
' text is inside
Else
' text is not inide
End If
使用InStr
函数:
If InStr(text1, text2) > 0 Then
if (InStr(text1, text2) > 0)
请查看http://msdn.microsoft.com/en-us/library/8460tsh1(v=vs.80).aspx,了解特殊情况(如参数为Nothing、空字符串等)。
RTM = InStr(1, text1,text2)
if RTM > 0 then debug.print "Text2 was found at position: "; RTM