How to remove "spaces" in a text string

1,578 views
Skip to first unread message

nap...@gmail.com

unread,
Jul 30, 2014, 8:30:27 AM7/30/14
to mitappinv...@googlegroups.com
Hi All,
I have 2 textboxes, textbox 1 = contains the first name, textbox 2 = counts the length of the of textbox1.  the problem is, if the first name has 2 or 3 first names like Stuwart John it should count as 11 and not 12(space gets counted as well)

this is my first time to use App Inventor.

Thanks,
Nap

Stephen Zipprich

unread,
Jul 30, 2014, 1:33:09 PM7/30/14
to mitappinv...@googlegroups.com
Check out the text blocks.  There are a couple ways you could eliminate a space.  There's another question you have to ask though: do you need to retain that space?  If you need to have that space in there for displaying the name later you're going to have to remember where that space was.  If Stuwart John is expecting his name to be displayed properly, he probably won't like seeing it written as StuwartJohn.

nap...@gmail.com

unread,
Jul 30, 2014, 5:50:23 PM7/30/14
to mitappinv...@googlegroups.com
hi Stephen,
yes actually I need to retain the space but for display purposes only, on another textbox I use length to get the total number of characters and on another textbox to manually input the number of spaces in the first name (this is a temporary solution though).

my next problem is if a text box is empty how do you tell that text box to have zero as its default value?

Thanks,
Nap

Scott Ferguson

unread,
Jul 30, 2014, 8:50:55 PM7/30/14
to mitappinv...@googlegroups.com
The Text replace all block can be used to remove spaces.
Just replace all [" "] (space character) with [""] (empty text)
---
sf

SteveJG

unread,
Jul 30, 2014, 9:32:34 PM7/30/14
to mitappinv...@googlegroups.com
" if a text box is empty how do you tell that text box to have zero as its default value?"

 if length textBox < 1 then set textBox = 0     perhaps?
Reply all
Reply to author
Forward
0 new messages