So I've created a calculator that computes your grades into your general average. But I have one problem, what if the user entered letters in each textboxes instead of numbers? I want to prevent them to use letters. So what're the codes for restricting the user from entering letters? I just need a code for a button. I will appreciate the help!
I've tried all the codes from the websites but all of them didn't work.
If emptyTextBoxes.Any Then
MsgBox("Please fill all the boxes before you press 'Compute'.", MsgBoxStyle.Critical, "GWA Calculator")
ElseIf Math.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or Eng.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or
Sci.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or Fil.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or
TL.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or IC.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or
MAP.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or Araling.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Or
ES.Text.Count(Function(c) Not Char.IsLetterOrDigit(c)) > 0 Then
MsgBox("One of the boxes has invalid characters", MsgBoxStyle.Critical, "GWA Calculator")
ElseIf (Math.Text.Length <> 2) Or (Eng.Text.Length <> 2) Or (Sci.Text.Length <> 2) Or (Fil.Text.Length <> 2) Or
(TL.Text.Length <> 2) Or (IC.Text.Length <> 2) Or (MAP.Text.Length <> 2) Or (Araling.Text.Length <> 2) Or
(ES.Text.Length <> 2) Then
MsgBox("One of the boxes contains 1 or 3 digits. It must contain 2 digits only to be computed.", MsgBoxStyle.Critical, "GWA Calculator")
At the second If statement, it only restricts this kind of characters: "/, ^, #, etc." I want to restrict letters also. Anyone can help me?
P.S. I'm using Windows Forms.