VB If the input is not a number, a pop-up window prompts

Determine whether the user input meets the requirements (whether it is a number), if it is not a number, a pop-up window will pop up

    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

Judging whether it is a number

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

 Judging whether it is an integer

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

Guess you like

Origin blog.csdn.net/sinat_56238820/article/details/123424280