Android Question One EditText never changes

DALB

Active Member
Licensed User
Good evening (8:30 PM)

In a app,

1)In module Main, There are 2 edittexts A and B submitted to two variables m1 or m2
Depending on the conditions m1 or m2, these edittexts take respectively the values A1,B1 or A2,B2.
2)The two variables are stored in a new one which is Starter.mainPV separated by the ":", giving A1:B1 or A2:B2.
3)The variable A1:B1 or A2:B2 is transferred to a module City
4)In this module City, with a Regex.Split(":",myVariable) I obtain separately (A1 and B1) or( A2 and B2).
5)The code below put them in 2 other edittexts which are txtPays.text(P) and txtVille.text(V).
6) Observation:
6.a) A1 is always put in txtPays.text(P) but never A2
6.b) B1 or B2 are correctly put in txtVille.text(V) depending of m1 or m2.
6.c) it's as if the txtPays.text editText could never change !!!

The code below belons to the module City

B4X:
'=====================================================
Sub paysVilleCourants_click
   
    Dim vp As String=Starter.mainVP

    If vp.Contains(":") Then

       Dim k() As String=Regex.Split(":",vp)
       Log("pays = " & k(0))
       txtPays.Text=k(0).trim
       txtVille.Text=k(1).trim
       Starter.ASource="main"
       pays_Click

    End If
   
End Sub

I've closed, restarted B4A, then restarted the computer, but nothing changed.

Is it a bug ? How to solve and find an issue ?

Thanks
 

emexes

Expert
Licensed User
I vaguely remember that the regex .Split function does not return blank last elements or something like that.

Perhaps just use the result of the string search eg:
B4X:
Dim ColonAt As Int = VP.IndexOf(":")
If ColonAt >= 0 Then
    txtPays.Text = VP.SubString2(0, ColonAt).Trim
    txtVille.Text = VP.Substring2(ColonAt + 1, VP.Length).Trim
End If
Not at computer so string function names might be not quite right ;-)

Also wondering why vp is not called pv, to match order of pays and ville components (just interested; is not life and death issue)
 
Upvote 0

DALB

Active Member
Licensed User
Thanks emexes, I'll try it soon !
 
Upvote 0

DALB

Active Member
Licensed User
All'right, it works ! Thanks to emexes.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…