2017-01-21 35 views
-1

我不知道如何使用這方面的工作,我有這個誰的投入將是一個有效的SSS或錫號碼(例如111-1111-111)如何在textboxin vb.net刪除文字

Example Picture

,我的代碼是:

Public Class Form1 

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged 
     If TextBox1.Text.Length = 4 Then 
      TextBox1.Text &= "-" 
      TextBox1.Select(TextBox1.Text.Length, 0) 
     ElseIf TextBox1.Text.Length = 11 Then 
      TextBox1.Text &= "-" 
      TextBox1.Select(TextBox1.Text.Length, 0) 
     End If 
    End Sub 
End Class 
+0

任何人都可以幫助我嗎? –

回答

1

使用MaskedTextBoxMask()屬性設置爲0000-000000-000。在輸入數字時將插入短劃線。

+0

不錯,它的作品感謝答案:D –