Text is contained

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to open a text file and read the file one line at a time. If the line
contains certain text, I want to branch and do something different. I
thought this would work:

If vbLine Like "pork" Then

but if the vbLine is "dog,cat,pork" it fails. How do I evaluate for a
portion of the vbLine variable? Other software I've used has a contains
operator:
vbLine!"pork" would mean does the vbLine contain "pork"
vbLine!!"pork" would mean does the vbLine variable NOT contain "pork"
Is there such a think in VBA?
 
I want to open a text file and read the file one line at a time. If the line
contains certain text, I want to branch and do something different. I
thought this would work:

If vbLine Like "pork" Then

but if the vbLine is "dog,cat,pork" it fails. How do I evaluate for a
portion of the vbLine variable? Other software I've used has a contains
operator:
vbLine!"pork" would mean does the vbLine contain "pork"
vbLine!!"pork" would mean does the vbLine variable NOT contain "pork"
Is there such a think in VBA?

In vba you could use the Instr function
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top