Use CInt to convert input value to integer : Data Type Convert « Data Type Functions « VBA / Excel / Access / Word






Use CInt to convert input value to integer

 
Sub cintDemo()
    Dim varMyInput
    Dim intMyVar As Integer
    
    varMyInput = InputBox("Enter an integer:", "10 Is True, Other Numbers Are False")
    intMyVar = CInt(varMyInput)
    MsgBox CBool(intMyVar = 10)
End Sub

 








Related examples in the same category

1.VBA's Functions for Simple Data Conversion
2.VBA's Functions for Complex Data Conversion
3.Using the Asc Function to Return a Character Code
4.Using the Str Function to Convert a Value to a String