Sign in to follow this  
pyromaniac4382

Checking Data Type in VB.Net

Recommended Posts

How would i check if a text box's text is an inter ger , and if it is not an integer , than how can i get it to tell me this i need this type if textbox1.text = integer then Messagebox.show ( " this is an integer") else Messagebox.show("This isnt an integer") end if Obviously this does not work.

Share this post


Link to post
Share on other sites

Module Module1

Sub Main()
If GetType(Integer) Is GetType(Char) Then
Console.WriteLine("1. An integer is an integer")
End If

If GetType(Integer) Is GetType(Integer) Then
Console.WriteLine("2. An integer is an integer")
End If

Dim x As Integer

If x.GetType() Is GetType(Integer) Then
Console.WriteLine("3. An integer is an integer")
End If


End Sub

End Module

Share this post


Link to post
Share on other sites
Thank you very much for you replies, they are a great help.
Btw , i will try to Put my posts in the right section next time.

What the program was , was a temperature conversion program, i needed the input to be an integer, then it would be passed and depending on which rdio button as checked it would convert it into that type. Any other methods, i want to know many.

Share this post


Link to post
Share on other sites
I have a natural aversion to VB's built-in functions, as they are non-portable between other .NET-friendly languages. [smile]

Bear in mind that IsNumeric doesn't check for integers; it will also handle floating-point values.

Share this post


Link to post
Share on other sites
Quote:
Original post by pyromaniac4382
what exactly is 'IsNumeric' checking for then?


Things that are, well, numeric. As in, interpretable as some kind of number. (Or at least, one of the types of number that's built into the language. Some mathematicians seem to make a hobby of inventing new kinds of numbers ;) )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this