A Andrew Lindsay Member Licensed User Longtime User Nov 29, 2014 #1 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 Code: Copy 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
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 Code: Copy 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 Nov 29, 2014 #2 Code: Copy 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 Code: Copy 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: Nov 29, 2014 Upvote 0
Code: Copy 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 Code: Copy 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
klaus Expert Licensed User Longtime User Nov 29, 2014 #3 This works: Code: Copy sKey = sKey.ToUpperCase sKey = sKey.Trim sKey = sKey.Replace("A", "B") Msgbox(sKey, "Key") Upvote 0
This works: Code: Copy sKey = sKey.ToUpperCase sKey = sKey.Trim sKey = sKey.Replace("A", "B") Msgbox(sKey, "Key")
A Andrew Lindsay Member Licensed User Longtime User Nov 29, 2014 #4 klaus said: This works: Code: Copy sKey = sKey.ToUpperCase sKey = sKey.Trim sKey = sKey.Replace("A", "B") Msgbox(sKey, "Key") Click to expand... Cheers guys. I was expecting them to be member functions of a class, therefore not explicitly requiring the 'sKey =' nomencalture. Thanks. Andrew Upvote 0
klaus said: This works: Code: Copy sKey = sKey.ToUpperCase sKey = sKey.Trim sKey = sKey.Replace("A", "B") Msgbox(sKey, "Key") Click to expand... Cheers guys. I was expecting them to be member functions of a class, therefore not explicitly requiring the 'sKey =' nomencalture. Thanks. Andrew