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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a string 1

Status
Not open for further replies.

FoxKid

MIS
Jun 8, 2003
92
0
0
IN
Hi All,
Assume that I am having 5 variable i.e. a,b,c,d,e, all are strings.
a='abc'
b='def'
c=' '
d='klm'
e=''

Now, I want it to be saved in a single string variable xtot. i.e
xtot='abc def klm'

There is all the posibilities of having any of these 5 strings to be blank except a. But in the xtot string, the gap between two string should not be greater that one space.
I know to do it with long procedure with <if> or <case>.
Is there any other way to do it.
Please suggest....

thanks and regards
 
You mention using IF - I assume you don't mean IIF() which is what I'd use:

xtot = a + iif(empty(b),[], b+[ ]) + iif(empty(c),[], c+[ ]) + iif(empty(d),[], d+[ ]) + iif(empty(e),[], e+[ ])

My example assumes that the variables are either empty or have 3 characters in them. If that's not the case, the IIF gets more complicated

I'd also check the help for how to use IIF().

Hope that helps,

Stewart
 
Sorry, my example should have started a + [ ] + iif(.......

Stewart
 
Thanks Stewart,
My problem is solved by your suggestion.
thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top