高分求救

shengxixi 2003-09-12 03:00:47
怎样使一个文本框只能输入两位数字,thanks
...全文
80 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
stonegoldaustin 2003-09-12
  • 打赏
  • 举报
回复
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <= 48 Or KeyAscii >= 57 Or Len(Text1.Text) >= 2 Then
KeyAscii = 0
End If
End Sub
danielinbiti 2003-09-12
  • 打赏
  • 举报
回复
Private Sub Form_Load()
Text1.MaxLength = 2
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 58 Then KeyAscii = 0
End Sub
haipingma 2003-09-12
  • 打赏
  • 举报
回复
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
End Sub

Private Sub Form_Load()
Text1.MaxLength = 2
End Sub

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧