功能最完善的:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 46 Then
If InStr(Text1.Text, ".") <> 0 Then
KeyAscii = 0
Exit Sub
Else
KeyAscii = 46
Exit Sub
End If
End If
If KeyAscii = 8 Then
KeyAscii = 8
ElseIf KeyAscii < 48 Or KeyAscii > 58 Then KeyAscii = 0
End If