vb来个会的

来源:百度知道 编辑:UC知道 时间:2024/05/30 01:34:35
只显示整数的代码
用checkbox来限制

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 Then
Dim re
Set re = CreateObject("VBScript.RegExp")
re.IgnoreCase = True
re.Global = True
re.Pattern = "^-?(\d+)?$"
If Not re.test(Text1.Text & Chr(KeyAscii)) Then
KeyAscii = 0
End If
End If
End Sub

print int(x)

if int(x)=x then print x

dim x as integer'dim x%

CInt()
Int()
Fix()

private sub text1_keypress(keyascii as integer)
if check1.value=1 then
if isnumeric(text1.text)=false then
keyascii=0
end if
end if
end sub