用一个简单的自定义函数来判断。
吴江ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
Function isint(s As String) As Boolean
Dim i%, j%
isint = True
If Left(s, 1) = "+" Or Left(s, 1) = "-" Then j = 2 Else j = 1
s = Trim(s)
For i = j To Len(s)
If Mid(s, i, 1) "0" Or Mid(s, i, 1) "9" Then isint = False
Next i
End Function
一、判断是否为数字且是否包含小数点:
IsNumeric(Text1) And InStr(1, Text1, ".", vbTextCompare)=0
二、计算:
Int(Val(Text1)) = Text1
Private Sub Command1_Click()
Dim i As Integer
i = Text1.Text
If i Mod 2 = 0 Then
MsgBox "偶数"
Else
MsgBox "奇数"
End If
End Sub
示例如下:
dim ss
ss =122.02
if ssint(ss) then
msgbox("非整数")
else
msgbox("整数")
end if