Android Question last 4 charachter of edittext

tufanv

Expert
Licensed User
Longtime User
Hello
I want to get last 4 charachters of what has been typed into edittext. Is there an easy way or code you can share ?

TY
 

tufanv

Expert
Licensed User
Longtime User
I cant do this with substring function because i have spaces before last 4 charachters i want to extract and those spaces are sometimes 3 sometimers 4 and sometimes 5 spaces. so cant get the last four with simple substring. sorry if i am missing stg
 
Upvote 0

eps

Expert
Licensed User
Longtime User
tufanv

can you give some examples of your data and then we can help a little more... It removes a lot of the guesswork.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
this is a part of the data :
B4X:
Buka Airport    AYBK
Chimbu Airport    AYCH
Daru Airport    AYDU
Goroka Airport    AYGA
Gurney Airport  AYGN
Girua Airport    AYGR
Kimbe Airport    AYHK
Kerema Airport        AYKM
Kavieng Airport  AYKV
Madang Airport    AYMD
Mount Hagen Kagamuga Airport    AYMH
Mendi Airport    AYMN
Momote Airport    AYMO
Lae Nadzab Airport    AYNZ
Port Moresby Jacksons International Airport    AYPY
Tokua Airport    AYTK

as you see there are at the end the 4 charachter icao codes of the airports. I need the extract this data from the autocompledeedittext
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
B4X:
dim txtTest2 as EditText
 
txtTest2.Text="Kerema Airport          AYKM"
Dim AirportCode As String=txtTest2.Text.SubString(txtTest2.Text.Length-4)
Msgbox(AirportCode,"")    'displays AYKM
 
  • Like
Reactions: eps
Upvote 0
Top