VB若输入不是数字弹出弹窗提示

判断用户输入是否符合要求(是否为数字) ,若不是数字弹出弹窗提示

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text Like "[a-z]" Then
            MsgBox("输入不是数字", vbOKOnly)
        ElseIf TextBox1.Text Like "[A-Z]" Then
            MsgBox("输入不是数字", vbOKOnly)
        'If UCase(ch) >= "A" And UCase(ch) <= "Z" Then'转换成全大写
        'If LCase(ch) >= "a" And LCase(ch) <= "z" Then'转换成全小写
        'If Asc(UCase(ch) >= 65 And Asc(UCase(ch) <= 90) Then'转换成asc码
        End If

判断是不是数字

If IsNumeric(ch) Then
    'If ch >= "0" And ch < "9" Then
    'If Asc(ch) >= 48 And Asc(ch) <= 57 Then
End If

 判断是不是整数

if Int(x)=x And Int(y)=y Then
 TextBox1.Text=x;
 TextBox2.Text=y;
End if

猜你喜欢

转载自blog.csdn.net/sinat_56238820/article/details/123424280