VB编程题,任意输入一个数,判定是否为整数。

2024-11-27 12:40:08
推荐回答(1个)
回答1:

Private Sub CommandButton1_Click()
Dim nNum As Long
If IsNumeric(TextBox1.Text) Then
nNum = Val(TextBox1.Text)
If nNum Mod 5 = 0 Then
MsgBox "能被5整除!", vbInformation, "提示"
Else
MsgBox "不能被5整除!", vbInformation, "提示"
End If
Else
MsgBox "输入不正确!", vbExclamation, "提示"
TextBox1.SetFocus
End If
End Sub