Judging by the fact that you have one type that you need to determine if it is an integer or another type, I assume that the number is contained in the string. If so, you can use the Integer.TryParse method to determine if this value is an integer, it also displays it as an integer if it succeeds, If that is not what you are doing, update your question with more information.
Dim number As String = 34.68 Dim output As Integer If (Integer.TryParse(number, output)) Then MsgBox("is an integer") Else MsgBox("is not an integer") End If
Edit:
You can use the same idea if you use decimal or another type to contain your number, n something like this.
Option Strict On Module Module1 Sub Main() Dim number As Decimal = 34 If IsInteger(number) Then MsgBox("is an integer") Else MsgBox("is not an integer") End If If IsInteger("34.62") Then MsgBox("is an integer") Else MsgBox("is not an integer") End If End Sub Public Function IsInteger(value As Object) As Boolean Dim output As Integer ' I am not using this by intent it is needed by the TryParse Method If (Integer.TryParse(value.ToString(), output)) Then Return True Else Return False End If End Function End Module
source share