试试看!
Private Sub Text4_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 46 Then KeyAscii = 0
If Left(Text4.Text, 1) = "0" And Mid(Text4.Text, 2, 1) <> "." And KeyAscii <> 46 And KeyAscii <> 8 Then Text4.Text = Right(Text4.Text, Len(Text4.Text) - 1)
If KeyAscii = Asc(".") And InStr(Text4.Text, ".") > 0 Then KeyAscii = 0
If Len(Text4.Text) > 3 And InStr(Right(Text4.Text, 4), ".") = 1 And KeyAscii <> 8 Then KeyAscii = 0
End Sub