- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- How to trim trailing blanks from a string
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
See the previous thread related to almost your query on string:
https://community.flexera.com/t5/InstallShield-Forum/Remove-Spaces-from-string-with-Installscript/m-p/40185
https://helpnet.flexerasoftware.com/installshield21helplib/Subsystems/installshield21langref/helplibrary/LangrefString_functions.htm
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
![](/skins/images/3B39CE851FDD5528C393F146EB70A2D0/responsive_peak/images/icon_anonymous_message.png)