what does Mod and Fix mean?

Rani

Well-known member
Joined
Nov 19, 2005
Messages
71
Programming Experience
Beginner
How does this work? Could you make me understand this please

1. values for recordcount = 2 and pagesize = 10

with mod i get D = 2

Dim D = (CInt(Me.lblRecordCount.Text) Mod CInt(Me.lblPageSize.Text))
and with div i get s = 0.2
Dim s = (CInt(Me.lblRecordCount.Text) / CInt(Me.lblPageSize.Text))

2. what does Fix do here?
Me.lblcounts.Text += CStr(Fix(CInt(Me.lblRecordCount.Text) / CInt(Me.lblPageSize.Text) + 1))

Thanks
 
I'm not sure what Fix is, but Mod is Modulus, which is basically the remainder you get from dividing two numbers

EDIT: Vis beat me to it :)
 
This is a bit confusing to me.

I refered to the example you provided in the link it says number1 divide by number2 remainder is the mod

so if that's the case in both below cases for recordcount being 2 initual value and pagesize being 10 initual value. shouldn't it be 2/10?

Dim D = (CInt(Me.lblRecordCount.Text) Mod CInt(Me.lblPageSize.Text))
Dim s = (CInt(Me.lblRecordCount.Text) / CInt(Me.lblPageSize.Text))

For D i get 2 and for s i get 0.2 dbl.

shouldn't be D = 0 and s = 0.2 ????
please make me understand.

 
The definition given in the link above for the Mod operator is "Divides two numbers and returns only the remainder." Returning only the remainder is the key here. If you divide 2 by 10, the answer without the remainder is zero so the remainder is 2.
 
The complement of Mod is "\", or integer division.

2 / 10 = 0.2R (R is short for Real, which indicates type Double)
2 \ 10 = 0I (I indicates type Integer)
2 Mod 10 = 2I
10 / 2 = 5.0R
10 \ 2 = 5I
10 Mod 2 = 0I

Fix() is a Runtime function that rounds a number towards zero. It is like the Int() function except that Int() rounds towards negative infinity.
 
Back
Top