在对一个表格第三列,和第四列控制,只能小数,和整数,语句如下,
Private Sub gd_KeyPress(KeyAscii As Integer)
If gd.Col = 2 Or gd.Col = 3 Then
If KeyAscii < 48 Or KeyAscii > 57 Then '48=is0,57 is9
MsgBox gd.Col & KeyAscii
KeyAscii = 0
End If
End If
结果不理想,如果先输入一个数字,在输入字母也能输入。如:9kdsjjd也能输入。怎么解决这个问题,
我这个语句还不能对小数进行判断,请高手帮改正一下。多谢。
Private Sub gd_KeyPress(KeyAscii As Integer)
If gd.Col = 2 Or gd.Col = 3 Then
If KeyAscii < 48 Or KeyAscii > 57 Then '48=is0,57 is9
MsgBox gd.Col & KeyAscii
KeyAscii = 0
End If
End If
结果不理想,如果先输入一个数字,在输入字母也能输入。如:9kdsjjd也能输入。怎么解决这个问题,
我这个语句还不能对小数进行判断,请高手帮改正一下。多谢。
解决方案 »
- 恳请高手帮忙 鼠标移到图片框中某一小区域时,显示一个文本框
- 在vb中怎样从一个二进制文件中取出字节,然后再转换成字符,存进文本文件中?在线等。急!!!
- 怎么样得到oracle数据库中LongRaw类型数据的长度?
- 因为数据库那边到现在还没人能解答,所以跑到这里来
- 将一个菜单项放到窗体最右边。
- 看看热闹!
- vb连接oracle数据库的插入问题
- vb查询语法错误iif(sql2000)
- 请教各位:如何制作帮助文件?
- 请教各位:关于 DataGrid 的 DblClick 事件
- 如何在VB中调用ORACLE的包?
- 谁有用TREEVIEW作的资源管理器################################################
Private Sub gd_KeyDown(KeyCode As Integer)
If gd.Col = 2 Or gd.Col = 3 Then
If KeyCode >= 48 and KeyAscii <= 57 Then '48=is0,57 is9
'MsgBox gd.Col & KeyAscii
'KeyAscii = 0
else
'MsgBox gd.Col & KeyAscii
'KeyAscii = 0
exit sub
End If
End If
结果不理想,如果先输入一个数字,在输入字母也能输入。如:9kdsjjd也能输入。怎么解决这个问题,
我这个语句还不能对小数进行判断,请高手帮改正一下。多谢。
Private Sub gd_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub'箭头键
If KeyAscii < 48 Or KeyAscii > 57 Then
Beep
If KeyAscii <> 46 Then KeyAscii = 0 '小数点可以
End If
End Sub
Private Sub gd_KeyPress(KeyAscii As Integer)
If gd.Col = 2 Or gd.Col = 3 Then
select case keyascii
case asc("0") to asc("9"),asc("."),vbkeytab,vbkeyback
case else
MsgBox gd.Col & KeyAscii
KeyAscii = 0
end select
End If
If KeyAscii = 13 Then Exit Sub
If InStr(".1234567890", Chr(CStr(KeyAscii))) = 0 Then
KeyAscii = 0
End If
End Sub
If keyascii < Asc("0") Or keyascii > Asc("9") Then
keyascii = 0 '取消输入
End If
End Sub
只是整数