1. Crea un Acumulador como variable de clase (del formulario):
2. Filtra los números en el evento KeyPress.
Si quieres que acumule de a uno los números ingresados:
Código vb.net:
Ver originalPrivate Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim KeyAscii
As Short = CShort(Asc(e
.KeyChar)) If InStr("1234567890",
Chr(Keyascii
)) = 0 Then e.Handled = True
Else
acumularNum
+= CInt(Chr(Keyascii
)) End If
End Sub
Si quieres que sólo los sume (completos) cuando presiones <Enter>:
Código vb.net:
Ver originalPrivate Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim KeyAscii
As Short = CShort(Asc(e
.KeyChar)) If InStr("1234567890",
Chr(Keyascii
)) = 0 Then e.Handled = True
Else
If e.KeyChar = ControlChars.Cr And TextBox1.Text <> "" Then
acumNum + = CInt(TextBox1.Text)
End If
End If
End Sub
Mas o menos así...