Göran Andersson said:
That's assuming that the decimal separator is a period, which it isn't
everywhere.
The decimal separator for any given culture can be found in the
NumberFormat.NumberDecimalSeparator property.
Couldn't you also do something along the lines of:
If IsNumeric(txt1.Text) Then
If CLng(txt1.Text) / 1 = CLng(txt1.Text) \ 1 Then
'Integer
Else
'Decimal
End If
End If
Or, if you're doing this a lot and making a decision based on it...
Public Function IsReal (ByVal Number As Object) As Integer
Dim i As Integer
i = -1 'Fail
If IsNumeric(Number) Then
If CLng(Number) / 1 = CLng(Number) \ 1 Then
i = 0 'Integer
Else
i = 1 'Real
End If
End If
Return i
End Function
If IsReal(txt1.Text) < 1 Then MessageBox.Show("I want a real!!!")
If IsReal(txt2.Text) <> 0 Then MessageBox.Show("I want an integerl!!!")
I've just realised that this wouldn't work for "4.000000", but I'll let you
have it anyway. :\