Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help countinvalue in a string

Status
Not open for further replies.

MrHelpMe

Technical User
May 1, 2001
203
CA
Hello everyone,

Need help ASAP trying to create a formula that says if the string contains 2 dashes then "xxx" else if it contains 1 then "xxx" else "xxx". Something like that. Is there anyway to count how many times in a formula a string displays a certain value. Hope this is clear. Thanks guys.
 
You can do this by using the replace and length funtions. Replace{@dashes} with the field you are checking.

stringvar dashes:={@dashes};
stringvar dout:=replace(dashes,"-","");
numbervar dcount:=length(dashes)-length(dout);
if dcount= 1 then "something" else
if dcount= 2 then "something else" else
"Yet another thing"

Mike
 
Thanks Mike,

This worked exactly like I wanted it too. How do you know this stuff. Is there any book I can read to help me with questions like this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top