iOS Question [SOLVED] B4XFloatTextField text problem

Chris Guanzon

Active Member
Licensed User
Longtime User
Hello, how can I match the text between two B4XFloatTextField? I am using this code, but I can't match the two B4XFloatTextField text. I also used the B4XFloatTextField.mbase.text, same result.

B4X:
Sub B4XFloatTextField6_TextChanged (Old As String, New As String)
    If B4XFloatTextField6.Text = "" And B4XFloatTextField7.Text = "" Then
        Label8.Text = ""
        SwiftButton3.Enabled = False
        Return
    End If
    
    If B4XFloatTextField6.mBase.Text <> "" And B4XFloatTextField7.mBase.Text = "" Then
        Label8.Text = ""
        SwiftButton3.Enabled = False
        Return
    End If
    
    If B4XFloatTextField7.Text <> B4XFloatTextField6.Text Then
        Label8.TextColor = 0xFFf44336
        Label8.TextSize = 12
        Label8.Text = "Confirm password is not matched with your password"
        SwiftButton3.Enabled = False
    Else
        Label8.TextColor = 0xFF4caf50
        Label8.TextSize = 12
        Label8.Text = "Password matched"
        SwiftButton3.Enabled = True
    End If
End Sub
 

mangojack

Expert
Licensed User
Longtime User
have you tried B4XFloatTextField.TextField

B4X:
Sub B4XFloatTextFieldPasswords_TextChanged (Old As String, New As String)
    If B4XFloatTextField6.TextField.Text = "" And B4XFloatTextField7.TextField.Text = "" Then
        Label8.Text = ""
        Return
    End If
  
    If B4XFloatTextField7.TextField.Text <> B4XFloatTextField6.TextField.Text Then
        Label8.Text = "Confirm password is not matched with your password"
    Else
        Label8.Text = "Password matched"
    End If

End Sub


I am guessing you might have the same / duplicate code in Sub B4XFloatTextField7_TextChanged ?

I believe it would be simpler for both Views to share the same Text_Changed event. (ie: B4XFloatTextFieldPasswords_TextChanged)
 
Upvote 0

roumei

Active Member
Licensed User
Don't use the .Text value within the TextChanged event. Use the string 'New' of the sub instead, it contains the current value.

Example for B4XFloatTextField2_TextChanged:
B4X:
Sub B4XFloatTextField2_TextChanged (Old As String, New As String)
    If B4XFloatTextField1.Text = "" And New = "" Then
        Label1.Text = ""
        SwiftButton1.Enabled = False
        Return
    End If
    
    If B4XFloatTextField1.Text = "" Then
        Label1.TextColor = 0xFFf44336
        Label1.TextSize = 12
        Label1.Text = "Password must have atleast 8-digit value"
        SwiftButton1.Enabled = False
        Return
    End If
    
    If New = "" Then
        Label1.Text = ""
        SwiftButton1.Enabled = False
        Return
    End If
    
    If New <> B4XFloatTextField1.Text Then
        Label1.TextColor = 0xFFf44336
        Label1.TextSize = 12
        Label1.Text = "Confirm password is not matched with your password"
        SwiftButton1.Enabled = False
    Else
        Label1.TextColor = 0xFF4caf50
        Label1.TextSize = 12
        Label1.Text = "Password matched"
        SwiftButton1.Enabled = True
    End If
    
End Sub
 
Upvote 0
Top