Weekly Qbasic and Qb64 Lesson Topics
March 28, 2024, 11:10:22 am
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Remove leading + trailing spaces from a $string.

Pages: [1]
  Print  
Author Topic: Remove leading + trailing spaces from a $string.  (Read 365 times)
guest
Guest
« on: May 29, 2011, 04:49:07 pm »


    Here's a common useful sub to remove spaces from both ends of a string. The string is passed to the sub and returned stripped.
Code:
REM
DEFLNG A-Z

SCREEN 12

b% = 123
a$ = STR$(b%)
'Trimer a$
PRINT a$, b%
SLEEP
SYSTEM

SUB Trimer (Temp$)
Temp$ = LTRIM$(RTRIM$(Temp$))
END SUB
You will note the leading space with the first printed value. Remove the REM to see the correctly trimmed result.

« Last Edit: September 14, 2011, 08:29:12 am by GarrisonRicketson » Report Spam   Logged

Share on Facebook Share on Twitter

Unseen Machine
Post Demos
*
Posts: 46


« Reply #1 on: May 30, 2011, 06:39:08 am »

THIEF!!! Grin

Just proves that great minds think alike!

http://www.qb64.net/forum/index.php?topic=3544.0

John
Report Spam   Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy