Android Question EditText manipulate text as entered - Solved

Discussion in 'Android Questions' started by padvou, Jun 2, 2015.

  1. padvou

    padvou Active Member Licensed User

    If I want an EditText to add a "-" after the first two digits, while the user enters numbers:
    for example:
    typed EditText shows
    1 1
    2 12
    3 12-3
    4 12-34
    5 12-345
    6 12-3456

    Can this be done?
  2. DonManfred

    DonManfred Expert Licensed User

  3. padvou

    padvou Active Member Licensed User

    Thank you.
    I'll keep working on it.
  4. fixit30

    fixit30 Active Member Licensed User

    You should look at the TextChanged event of EditText
    padvou likes this.
  5. padvou

    padvou Active Member Licensed User

    Here's what I came up with:
    Sub EditText1_TextChanged (Old As String, New As String)

    If Old.Length<New.Length Then
    If Old.Length=2 Then
    0,2) & "-"
    End If
    End If
    End Sub
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice