对输入的数据进行验证、限制和修改 (1)修改输入数据,让控件只能接收大写字符 将 Keypreview设置为Tue,并写下列 Form Key Press事件代码 Sub Form Key Press(KeyAscii As Integer) lfKeyAscii>=Asc("a")And KeyAscii<=Asc(z) Then KeyAscii= KeyAscii-(Asc("a")-ASc("A)) End lf End sub Limes/ (2)限制数据输入,让文本框89的数字字 写下列文本框的 Keypress事件代码: Sub txtExample keypress(KeyAscii As Integer) if KeyAscii<48 Or KeyAscii> 57Then KeyAscii=o End jf.1 End sub对输入的数据进行验证、限制和修改 (1) 修改输入数据,让控件只能接收大写字符 将KeyPreview设置为True,并写下列Form_KeyPress事件代码: Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then KeyAscii = KeyAscii – ( Asc("a") - Asc("A") ) End If End Sub (2)限制数据输入,让文本框只能接收“0”~“9”的数字字符 写下列文本框的KeyPress事件代码: Sub txtExample_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 End If End Sub