Whats an easy to change a double value with a fraction to an integer value. Thanks
Printable View
Whats an easy to change a double value with a fraction to an integer value. Thanks
I am thinkingorCode:CInt(3.2)
.Code:Int(3.2)
It may be better to use Convert.
Note, converting a double to a integer will create rounding of the decimal portion of the value.Code:Dim dblTest As Double = 5.88888
Dim iTest As Integer
iTest = Convert.ToInt32(dblTest)
MessageBox.Show(iTest.ToString, "Test")
Be careful when you do a narrowing conversion like this... It could result in buffer overflow if the value of the double (64 bits) is larger than the value that an integer (32 bits) can hold.