展开全部
可以让文本框只能接收数字物枝:代码如下
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii <> 13 Then
Select Case Chr(KeyAscii)
Case "0" To "9"
Case Else
KeyAscii = 0
End Select
End If
End Sub
至于数字范围(0-100),要写LostFocus()事件,代码如下:丛纤
Private Sub Text1_LostFocus()
Text1.Text = Trim(Text1.Text)
v = Val(Text1.Text)
If v < 0 Or v > 100 Then
MsgBox ("输入超出范围罩郑敏!")
Text1.SetFocus
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii <> 13 Then
Select Case Chr(KeyAscii)
Case "0" To "9"
Case Else
KeyAscii = 0
End Select
End If
End Sub
至于数字范围(0-100),要写LostFocus()事件,代码如下:丛纤
Private Sub Text1_LostFocus()
Text1.Text = Trim(Text1.Text)
v = Val(Text1.Text)
If v < 0 Or v > 100 Then
MsgBox ("输入超出范围罩郑敏!")
Text1.SetFocus
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询