J
Jim B
I am new to VB.NET and have a question on validating user input from a
Text Box. I'm writing a small program where I want to check the users
input data and determine if it's an Integer or a Decimal. I guess I
want to go one step further than just checking for IsNumeric. I have
searched this Work Groups' database and did not find exactly what I
need. I have tried GetType, VarType, and the Val Function using the
Text Box data, without success. I did find, however, that I could
assign the data directly to a variable and the above work fine, so it
must be how I am trying to get the data from the Text Box.
Since the Text Box information is Text, I assume I need to convert it
to numeric before checking it. But, All I've found is conversions to
specific types (Integer, Double, etc), and not into just numeric.
That doesn't seem to help me with what I'm trying to do. What am I
missing?
This is the code I'm using to try to make this validation:
Dim TestData
TestData = TBoxInput.Text
‘What needs to go here??
If VarType(TestData) = VariantType.Integer Then
TBoxResult.Text = "It's an Integer"
End If
I assume there must be a simple solution to this problem, but I just
haven't found it. Any help would be greatly appreciated.
Jim B
Text Box. I'm writing a small program where I want to check the users
input data and determine if it's an Integer or a Decimal. I guess I
want to go one step further than just checking for IsNumeric. I have
searched this Work Groups' database and did not find exactly what I
need. I have tried GetType, VarType, and the Val Function using the
Text Box data, without success. I did find, however, that I could
assign the data directly to a variable and the above work fine, so it
must be how I am trying to get the data from the Text Box.
Since the Text Box information is Text, I assume I need to convert it
to numeric before checking it. But, All I've found is conversions to
specific types (Integer, Double, etc), and not into just numeric.
That doesn't seem to help me with what I'm trying to do. What am I
missing?
This is the code I'm using to try to make this validation:
Dim TestData
TestData = TBoxInput.Text
‘What needs to go here??
If VarType(TestData) = VariantType.Integer Then
TBoxResult.Text = "It's an Integer"
End If
I assume there must be a simple solution to this problem, but I just
haven't found it. Any help would be greatly appreciated.
Jim B