Android Question trim()

BlueVision

Active Member
Licensed User
Longtime User
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:

Example:
    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

Cableguy

Expert
Licensed User
Longtime User
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

teddybear

Well-Known Member
Licensed User
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

Theera

Well-Known Member
Licensed User
Longtime User
If you used to vb6.0 coding,try using B4XStringFunctionVB.
 

Attachments

  • B4XStringFunctionVB.b4xlib
    6.3 KB · Views: 91
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Trim function only removes trailling spaces!!!! as oposed to all spaces in a string.
1694943909534.png


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