'只允许输入0至9以及倒退键的示例If (e.KeyChar >= Chr(Asc("0")) And e.KeyChar <= Chr(Asc("9"))) Or e.KeyChar = Chr(8) Then Exit Sube.KeyChar = Chr(0) ‘拦截其他键值