cancel
Showing results for 
Search instead for 
Did you mean: 
FlexeraFan
Occasional contributor

How to trim trailing blanks from a string

Jump to solution

1.)How can I trim trailing blanks from a string? I need to check if a string is empty. If it is not then I need to perform an action.

Example:  hString = "                        ";

2.)Is there a single command which will trim trailing blanks? Also what if someone enters a tab and it is saved in the string? How would I ignore tab characters?

Labels (1)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Flexera Varaprasad
Flexera

Re: How to trim trailing blanks from a string

Jump to solution

StrTrim does not return string, hence modify

         exampleString = StrTrim(exampleString );

to

        StrTrim(exampleString ); // exampleString passed as reference, hence changes will be reflected  back

 

You can refer below link for return values of StrTrim method

https://helpnet.flexerasoftware.com/installshield22helplib/Subsystems/installshield22langref/helplib...

View solution in original post

4 Replies
Flexera Varaprasad
Flexera

Re: How to trim trailing blanks from a string

Jump to solution

There is no built-in method to remove trailing spaces alone. You can use StrTrim to remove both the leading and trailing spaces and tabs from a string

or

You can write your own method as your requirement. You can find example here.


https://community.flexera.com/t5/InstallShield-Knowledge-Base/String-Indexing-Example/ta-p/4526

ralphster
Active participant

Re: How to trim trailing blanks from a string

Jump to solution

I tried using StrTrim but I am getting an error message :  "string value required". Does anyone have any idea why this is happening?

 

string exampleString = "          ";
exampleString = StrTrim(exampleString ); // Gives compile error message "string value required".

0 Kudos
Highlighted
Flexera Varaprasad
Flexera

Re: How to trim trailing blanks from a string

Jump to solution

StrTrim does not return string, hence modify

         exampleString = StrTrim(exampleString );

to

        StrTrim(exampleString ); // exampleString passed as reference, hence changes will be reflected  back

 

You can refer below link for return values of StrTrim method

https://helpnet.flexerasoftware.com/installshield22helplib/Subsystems/installshield22langref/helplib...

View solution in original post