Eingabeformat

  • VB.NET

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von Faulenzer89.

    klar gibt es eine ^^
    es gibt sogar mehrere
    (ich denke die einfachere)
    indem du das keydown event abfängst (in der tb) in die tb den text "/" hinzufügst und dann in eine globale variable als string den eigendlichen key anhängst

    oder (schwieriger)
    du machst es mit nem label ;)
    Erstmal danke für deinen Tipp. Aber irgendwie funktionniert es nicht. Habe bis jetzt folgenden Code:

    VB.NET-Quellcode

    1. Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
    2. If Not e.KeyCode = Keys.Back Then
    3. If Len(TextBox1.Text) = 3 Then
    4. If TextBox1.SelectionStart = 3 Then
    5. TextBox1.Text = TextBox1.Text & " / "
    6. TextBox1.SelectionStart = TextBox1.Text.Length
    7. End If
    8. End If
    9. If Len(TextBox1.Text) = 3 Then
    10. TextBox1.Text = TextBox1.Text & " / "
    11. TextBox1.SelectionStart = TextBox1.Text.Length
    12. End If
    13. If Len(TextBox1.Text) = 9 Then
    14. TextBox1.Text = TextBox1.Text & " "
    15. TextBox1.SelectionStart = TextBox1.Text.Length
    16. End If
    17. If Len(TextBox1.Text) = 12 Then
    18. TextBox1.Text = TextBox1.Text & " "
    19. TextBox1.SelectionStart = TextBox1.Text.Length
    20. End If
    21. End IfEnd Sub


    Ich möchte folgendes Eingabeformat: ### / ### ## ##

    Das Problem liegt nun darin, wenn ich etwas löschen will, werden die Leerschläge nicht gemacht (z.B. 123 / 456 7889 ). Diese sollten automatisch gesetzt werden.