0

Every time someone types in a decimal or any characters or strings, I want a message box shown saying “only integers”.

1 Answers1

0

In .net as your tag says: Try pasting this in some event of the Textbox, for example the Lostfocus. Remember to add the Namespace part:

Imports System.Text.RegularExpressions 'At the top of the form class

 Public Class FormName

 Private Sub Tbx_EscuelaElegida_LostFocus(.....

 'DECLARE VARIABLE AND ASSIGN THE TEXTBOX CONTENT TO IT
    Dim TestsVariable As String = TextboxName.text


    'IF IT DOES NOT CONTAIN INTEGERS, SHOW A MESSAGE
    If Not Regex.IsMatch(TestsVariable, "^[0-9 ]+$") Then

        MsgBox("No Decimal Numbers")

    End If

 End sub
End Class
  • 1
    I believe this is VB.net? OP requests C#. – DaniDev Feb 28 '18 at 00:56
  • I know, Dani. I just answered that because if you look at his tags he included ".net" . So I thought he might know how to write some code in ".net", too and then adapt it to C# :D – Sergio Frías Feb 28 '18 at 01:26