Android Question trim()

You can put it as a "suffix" to almost any type of string. Try to append ".Trim" within the IDE.
There is also a combination of Suffixes possible:

Code: Copy
    Dim sample As String = "  My NaMe Is DoNaLd DuCk  "
    Log(sample.Trim.ToLowerCase)
    Log(sample.Trim.ToUpperCase)
    Log(sample.SubString2(3,6))

1st log-line creates -> 'my name is donald duck'
2nd log-line creates -> 'MY NAME IS DONALD DUCK'
3rd log-line creates -> 'y N'

Play with it!
 
Upvote 0
Friends, how to use the trim() function to remove white spaces from text?
Trim function only removes trailling spaces!!!! as oposed to all spaces in a string.
 
Upvote 0
Trim function only removes trailling spaces!!!! as oposed to all spaces in a string.
Actually the trim will return a copy of orignal string without any leading or trailing white spaces in B4X.
 
Upvote 0
If you used to vb6.0 coding,try using B4XStringFunctionVB.
 

Attachments

Upvote 0
Trim function only removes trailling spaces!!!! as oposed to all spaces in a string.
1694943909534.png


To remove ALL spaces:
B4X: Copy
Var = Var.Replace(" ", "")
 
Upvote 0
Back
Top