iOS Question Baby Steps

Andrew Lindsay

Member
Licensed User
Longtime User
Hello again, I am slowly getting into programming with B4i, but I am having trouble with some simple string functions.
I have the following code
B4X:
	sKey = TXT_CKEY.Text
	sKey.ToUpperCase
	sKey.Trim
	sKey.Replace("A", "B")
	Msgbox(sKey, "Key")

In thsi rather trivial example, I would expect the "A" characters in the text field would be replaced with 'B", but in fact, nothing changes.

Obviously I am doing something wrong, but can't work out what that something is...

Best regards
Andrew
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim sKey As String = "AbcdtAejjkcAie"
Msgbox(sKey.ToUpperCase.Trim.Replace("A", "B"), "Key")

The Stringfunctions have an resultvalue (ToUppercase will make everything uppercase). You need to USE that returnvalue.
you could write the above like this to understand
B4X:
sKey = TXT_CKEY.Text
sKey = sKey.ToUpperCase
sKey = sKey.Trim
sKey = sKey.Replace("A", "B")

Edit: Oups... it´s the iOS-forum... I hope B4I-stringfunctions will work like the ones in B4A. I don´t know whether the above will work on B4I but intuitive it should work on B4I too
 
Last edited:
Upvote 0

Andrew Lindsay

Member
Licensed User
Longtime User
This works:
B4X:
sKey = sKey.ToUpperCase
sKey = sKey.Trim
sKey = sKey.Replace("A", "B")
Msgbox(sKey, "Key")

Cheers guys. I was expecting them to be member functions of a class, therefore not explicitly requiring the 'sKey =' nomencalture.

Thanks.
Andrew
 
Upvote 0
Top