Код:
Private Sub txtSum_KeyPress(KeyAscii As Integer)
KeyAscii = Only_Number(KeyAscii)
End Sub

Function Only_Number(theParam As Integer)
If InStr("1234567890" & Chr(8), Chr(theParam)) > 0 Then
Only_Number = theParam
Else
Only_Number = 0
End If
End Function