Para VB este es el código
Public
Class Form1
Private Sub Form1_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If Char.IsLetter(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar)
Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
End
Class
using
Microsoft.VisualBasic;
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.Data;
using
System.Diagnostics;
Public Class Form1
{
private
void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if
(char.IsLetter(e.KeyChar)) {
e.Handled = false;
} else
if (char.IsControl(e.KeyChar)) {
e.Handled = false;
} else
if (char.IsSeparator(e.KeyChar)) {
e.Handled = false;
} else
{
e.Handled = true;
}
}
Public
Form1()
{
KeyPress += Form1_KeyPress;
}
}