例如:文本框的名称为 Text1。Private Sub Text1_KeyPress(KeyAscii As Integer)If InStr(Text1.Text, ".") And KeyAscii = 46 Then KeyAscii = 0End IfEnd SubInStr 函数检查是否存在“.”,KeyAscii = 46 表示按下“.”时。整个意思就是:如果存在“.” 与 按下“.” 那么,KeyAscii = 0 屏蔽。