Судя по тому, что у вас есть один тип, который вы нуждающихся, чтобы определить, является ли это целое число или другой тип Я предполагаю, что число содержится в строке. Если это так, вы можете использовать метод Integer.TryParse, чтобы определить, является ли это значение целым, оно также выводит его как целое, если оно выполнено успешно. Если это не то, что вы делаете, уточните свой вопрос с дополнительной информацией.
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:
Вы можете использовать ту же самую идею, если вы используете Decimal или другого типа, чтобы содержать свой номер, н что-то вроде этого.
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
Какой тип переменной, которая используется, чтобы содержать свой номер, это строка ?. –