繁体   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