iOS Question String edit

mare1980k1

Member
Licensed User
Longtime User
I am struggling so much with this...
I have a string called password (randomly generated, long between 8 and 24 characters) and i want to delete the last character of that string. I've tried with substring2 but i don't really understand how it works, so any help would be really appreciated.
Thanks in advance
 

tufanv

Expert
Licensed User
Longtime User
I am struggling so much with this...
I have a string called password (randomly generated, long between 8 and 24 characters) and i want to delete the last character of that string. I've tried with substring2 but i don't really understand how it works, so any help would be really appreciated.
Thanks in advance
Hello,

Substring2 cuts a portion of a string with starting and ending characters. Let's say your password string is tufan123 and you want to delete last char and have tufan12
starting point is 0 as we will not cut anything from the starting point
ending point will be the length-1 so

for example :
B4X:
    Dim s As String="tufan123"
    Log(s.SubString2(0,s.Length-1))

another example:

you want to have fan123 instead of tufan123 you have to start from index 2 meaning 3rd char . Don't forget starting point is inclusive and ending point is exclusive, if ending point was inclusive too you had to use length-1 instead of length :

B4X:
    Dim s As String="tufan123"
    Log(s.SubString2(2,s.Length))
 
Last edited:
Upvote 0
Top