Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'Chr(48) ถึง Chr(57) คือตัวเลข 0-9
'Chr(8) คือ Back space
If (Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57) and Asc(e.KeyChar) <>8 Then
e.Handled = True
MsgBox("ป้อนค่าแม่สูตรคูณที่เป็นตัวเลขได้เท่านั้น", vbOKOnly)
End If
End Sub