validating numbers in a textbox
-
I'm writing a program that converts a number in a textbox from one metric unit to another. I need to write an if statement that will validate that what is in the textbox is a numer and if it isn't returns a message box. any suggestions with code samples would be appreciated. BINARY
-
I'm writing a program that converts a number in a textbox from one metric unit to another. I need to write an if statement that will validate that what is in the textbox is a numer and if it isn't returns a message box. any suggestions with code samples would be appreciated. BINARY
Try the
Parse
method in theInt32
class. Something likeDim number as Int32
Try
number = Int32.Parse(textBox.Text)
Catch
// Show Messagebox hereRegards Senthil _____________________________ My Blog | My Articles | WinMacro
-
I'm writing a program that converts a number in a textbox from one metric unit to another. I need to write an if statement that will validate that what is in the textbox is a numer and if it isn't returns a message box. any suggestions with code samples would be appreciated. BINARY
Why not do it the smart way and use one of the many controls on this site that give you a text box which only accepts numbers ? Otherwise, I'd use a regular expression to pull a number out before I did a try/catch, that's just ugly. Christian Graus - Microsoft MVP - C++
-
Why not do it the smart way and use one of the many controls on this site that give you a text box which only accepts numbers ? Otherwise, I'd use a regular expression to pull a number out before I did a try/catch, that's just ugly. Christian Graus - Microsoft MVP - C++
I ended up using IsNumeric to validate the textbox. Thanx all. BINARY
-
I ended up using IsNumeric to validate the textbox. Thanx all. BINARY