Funkcje VBA Int i Fix zwracają część całkowitą liczby.
Int(liczba)
Fix(liczba)
Używanie funkcji Int i Fix do konwersji różnych typów wartości numerycznych, co pomaga również lepiej zrozumieć różnicę w przypadku wartości ujemnych:
Sub IntFixExample()
MsgBox Int(1) 'Zwroty: 1
MsgBox Fix(1) 'Zwroty: 1
MsgBox Int(-1) 'Zwroty: -1
MsgBox Fix(-1) 'Zwroty: -1
MsgBox Int(2.9) 'Zwroty: 2
MsgBox Fix(2.9) 'Zwroty: 2
MsgBox Int(-2.9) 'Zwroty: -3
MsgBox Fix(-2.9) 'Zwroty: -2
MsgBox Int(4.5) 'Zwroty: 4
MsgBox Fix(4.5) 'Zwroty: 4
MsgBox Int(-4.5) 'Zwroty: -5
MsgBox Fix(-4.5) 'Zwroty: -4
MsgBox Int(0.424) 'Zwroty: 0
MsgBox Fix(0.424) 'Zwroty: 0
MsgBox Int("13") 'Zwroty: 13
MsgBox Fix("13") 'Zwroty: 13
MsgBox Int("-4.5") 'Zwroty: -5
MsgBox Fix("-4.5") 'Zwroty: -4
MsgBox Int(True) 'Zwroty: -1
MsgBox Fix(True) 'Zwroty: -1
MsgBox Int(False) 'Zwroty: 0
MsgBox Fix(False) 'Zwroty: 0
End Sub