Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if text1 contains text2 using vb6?

Tags:

vb6

How to check if text1 contains text2 using 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
like image 832
faressoft Avatar asked Dec 31 '10 16:12

faressoft


People also ask

How do you check if a string contains a substring in vb6?

In visual basic, the string Contains method is useful to check whether the specified substring exists in the given string or not and it will return a boolean value. In case, if substring exists in a string, then the Contains method will return true otherwise it will return false.

How do you check if a string contains a character VB?

contains method in vb.net. Contains method of the string class determine that the substring is present inthe string or not, or we can say contains method checks whether specified parameter string exist inthe string or not. this method returns boolean type value true and false.


1 Answers

You can use InStr function like this:

Dim position As Integer

position = InStr(1, stringToSearch, stringToFind)

If position > 0 Then
  ' text is inside
Else
  ' text is not inide 
End If
like image 118
Sarfraz Avatar answered Sep 30 '22 19:09

Sarfraz