Finding substrings within a string

  • Thread starter Thread starter Gaston
  • Start date Start date
G

Gaston

Sorry if this question seems trivial, but for the life of me, I can'
figure out how to search for something within a string.

Say I got str1="ABC" and str2="AAA AAB AAC ABC ABC"
I want to be able to search str2 and see if str1 exists within it.

Thanks in advanced
 
H

Try
str1 = "ABc
str2 = "AAA AAB AAC ABC ABC

MsgBox InStr(1, str2, str1, 1

Ton

----- Gaston > wrote: ----

Sorry if this question seems trivial, but for the life of me, I can'
figure out how to search for something within a string

Say I got str1="ABC" and str2="AAA AAB AAC ABC ABC
I want to be able to search str2 and see if str1 exists within it.

Thanks in advanced
 
dim str2 as string
dim str1 as string
dim iplace as integer
dim start as integer
start = 1
iplace = InStr(start,str2,str1)
if iplace = 0 then
'not found
else
' iplace is set the the beginning of the in str2
' where str1 is located
end if
 
Back
Top