cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
FlexeraFan
Level 5

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

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/helplibrary/StrTrim.htm?

View solution in original post

(4) Replies
Varaprasad
Level 7 Flexeran
Level 7 Flexeran

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

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

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/helplibrary/StrTrim.htm?