if statement

Status
Not open for further replies.
J

Joel Allen

Hello,

I'm trying to make an if statement that finds a part of the value. For

example:

If Item.UserProperties("test") = "Apple", my if statement could find the

"ppl" in it regardless of case sensitivity.

if Item.UserProperties("test") has "ppl" in it, then......

Hope that make sense, thanks, Joel
 
The function you're looking for is Instr():

myString = Item.UserProperties("test")

If Instr(1, myString, "ppl", vbTextCompare) > 0 Then

MsgBox "myString contains ppl"

End If

Sue Mosher

"Joel Allen" <joelallen123@hotmail.com> wrote in message

news:en7ohAM1JHA.1196@TK2MSFTNGP03.phx.gbl...
> Hello,

> I'm trying to make an if statement that finds a part of the value. For
> example:

> If Item.UserProperties("test") = "Apple", my if statement could find the
> "ppl" in it regardless of case sensitivity.

> if Item.UserProperties("test") has "ppl" in it, then......

> Hope that make sense, thanks, Joel
>
 
Thanks. What if I wanted to search for multiple items? I want search for

tbd, N30, etc.... This is not working.

Instr(1, Item.UserProperties("PaymentTerms"), "tbd", "N30", "etc....",

vbTextCompare) > 0

Thanks for your help. I tried to go to VB help, but there's no

documentation about this. Do you have a good reference for syntax questions

like this so I don't have to keep bugging you?

"Sue Mosher [MVP]" <suemvp@turtleflock.com> wrote in message

news:%23X16HIM1JHA.1420@TK2MSFTNGP04.phx.gbl...
> The function you're looking for is Instr():

> myString = Item.UserProperties("test")
> If Instr(1, myString, "ppl", vbTextCompare) > 0 Then
> MsgBox "myString contains ppl"
> End If

> > Sue Mosher
> > >

> "Joel Allen" <joelallen123@hotmail.com> wrote in message
> news:en7ohAM1JHA.1196@TK2MSFTNGP03.phx.gbl...
> > Hello,
>

>> I'm trying to make an if statement that finds a part of the value. For
> > example:
>

>
>> If Item.UserProperties("test") = "Apple", my if statement could find the
> > "ppl" in it regardless of case sensitivity.
>

>> if Item.UserProperties("test") has "ppl" in it, then......
>

>> Hope that make sense, thanks, Joel
> >


>
 
You'd need to repeat the Instr() statement for each string you want to

search for. An array might be handy for managing the different search

strings.

You can easily look up the syntax for Instr() by typing it into your code

module, putting the cursor on it, and then pressing F1.

Sue Mosher

"Joel Allen" <joelallen123@hotmail.com> wrote in message

news:Ot739IY1JHA.4632@TK2MSFTNGP02.phx.gbl...
> Thanks. What if I wanted to search for multiple items? I want search for
> tbd, N30, etc.... This is not working.

> Instr(1, Item.UserProperties("PaymentTerms"), "tbd", "N30", "etc....",
> vbTextCompare) > 0

> Thanks for your help. I tried to go to VB help, but there's no
> documentation about this. Do you have a good reference for syntax
> questions like this so I don't have to keep bugging you?

> "Sue Mosher [MVP]" <suemvp@turtleflock.com> wrote in message
> news:%23X16HIM1JHA.1420@TK2MSFTNGP04.phx.gbl...
> > The function you're looking for is Instr():
>

>> myString = Item.UserProperties("test")
> > If Instr(1, myString, "ppl", vbTextCompare) > 0 Then
> > MsgBox "myString contains ppl"
> > End If
>

>> "Joel Allen" <joelallen123@hotmail.com> wrote in message
> > news:en7ohAM1JHA.1196@TK2MSFTNGP03.phx.gbl...
> >> Hello,
> >
>>> I'm trying to make an if statement that finds a part of the value. For
> >> example:
> >
>>
>>> If Item.UserProperties("test") = "Apple", my if statement could find the
> >> "ppl" in it regardless of case sensitivity.
> >
>>> if Item.UserProperties("test") has "ppl" in it, then......
> >
>>> Hope that make sense, thanks, Joel
> >>

>

>>


>
 
Status
Not open for further replies.

Similar threads

Back
Top