簡體   English   中英

使用“蒙版”文本框分隔數字

[英]Separate Number using Masked textbox

我不知道該如何使用,我要輸入的是有效的sss或tin編號(例如111-1111-111)

示例圖片

我的代碼是:

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

使用MaskedTextBox並將Mask()屬性設置為0000-000000-000 在輸入數字時,將為您插入破折號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM