• Sorry, I don't use VB, but I can show you how to do it in C#. string x is the string input by the user: if (x.Contains(".")) MessageBox.Show("Decimal numbers not accepted"); Simple, eh?
  • Let's say the textbox we will receive input from is called InNumber. We could do this: Dim IntPart As Integer Dim Full As Double IntPart = Int(Val(InNumber.Text)) 'IntPart holds 4 Full = Val(InNumber.Text) 'Full holds 4.7 If (Full - IntPart > 0) Then 'Difference is 0.7 MsgBox("Only Integers") 'Not an integer End If Something similar to this should work. Another example would be if we used the number 19, in this case an integer. IntPart would be 19 and Full would be 19. Subtract them and you get 0, so the message is not displayed.

Copyright 2020, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy