Как проверить, содержит ли text1 текст2, используя vb6?
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 следующим образом:
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 для особых случаев (параметры - Ничто, пустые строки и т. Д.)
RTM = InStr(1, text1,text2) if RTM > 0 then debug.print "Text2 was found at position: "; RTM