Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: How to check if a variable exists within another variable

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How to check if a variable exists within another variable
"Xs4all" <zpooky[ at ]xs4all.nl> 12.07.2006 09:39:13
Hi,

I have 2 variables:

A="Fox"
B="The quick brown fox"

How can I check if variable B contains variable A? Something like: "IF (A is
part of B) THEN TRUE"

Is that possible in VBA?

Thanks


Re: How to check if a variable exists within another variable
"Jonathan West" <jwest[ at ]mvps.org> 12.07.2006 09:44:05

"Xs4all" <zpooky[ at ]xs4all.nl> wrote in message
news:44b4c354$0$31647$e4fe514c[ at ]news.xs4all.nl...
[Quoted Text]
> Hi,
>
> I have 2 variables:
>
> A="Fox"
> B="The quick brown fox"
>
> How can I check if variable B contains variable A? Something like: "IF (A
> is part of B) THEN TRUE"
>
> Is that possible in VBA?
>
> Thanks

Look up the InStr function in VBA Help. Also look up "Like", "LCase" and
"UCase". There are code examples in the Help which will point you in the
right direction.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org


Re: How to check if a variable exists within another variable
"Jezebel" <warcrimes[ at ]whitehouse.gov> 12.07.2006 10:12:10
if instr(B,A) > 0 then
...



"Xs4all" <zpooky[ at ]xs4all.nl> wrote in message
news:44b4c354$0$31647$e4fe514c[ at ]news.xs4all.nl...
[Quoted Text]
> Hi,
>
> I have 2 variables:
>
> A="Fox"
> B="The quick brown fox"
>
> How can I check if variable B contains variable A? Something like: "IF (A
> is part of B) THEN TRUE"
>
> Is that possible in VBA?
>
> Thanks
>


Re: How to check if a variable exists within another variable
"Xs4all" <pooky_geen_spam[ at ]sd.nl> 12.07.2006 10:43:58
Perfect!!

Thanks

"Jezebel" <warcrimes[ at ]whitehouse.gov> wrote in message
news:e%23bSouZpGHA.1440[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> if instr(B,A) > 0 then
> ...
>
>
>
> "Xs4all" <zpooky[ at ]xs4all.nl> wrote in message
> news:44b4c354$0$31647$e4fe514c[ at ]news.xs4all.nl...
>> Hi,
>>
>> I have 2 variables:
>>
>> A="Fox"
>> B="The quick brown fox"
>>
>> How can I check if variable B contains variable A? Something like: "IF (A
>> is part of B) THEN TRUE"
>>
>> Is that possible in VBA?
>>
>> Thanks
>>
>
>


Re: How to check if a variable exists within another variable
"Xs4all" <pooky_geen_spam[ at ]sd.nl> 12.07.2006 11:35:59
Thanks!

"Jonathan West" <jwest[ at ]mvps.org> wrote in message
news:Ou1NeIapGHA.4208[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
>
> "Xs4all" <zpooky[ at ]xs4all.nl> wrote in message
> news:44b4c354$0$31647$e4fe514c[ at ]news.xs4all.nl...
>> Hi,
>>
>> I have 2 variables:
>>
>> A="Fox"
>> B="The quick brown fox"
>>
>> How can I check if variable B contains variable A? Something like: "IF (A
>> is part of B) THEN TRUE"
>>
>> Is that possible in VBA?
>>
>> Thanks
>
> Look up the InStr function in VBA Help. Also look up "Like", "LCase" and
> "UCase". There are code examples in the Help which will point you in the
> right direction.
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net