• Status: Solved
• Priority: Medium
• Security: Public
• Views: 712

# fMod in VB

Is there any PREMADE function of fMod in VB ?

I need to phrase some numbers and would like to use a internal function for this... the current way just "feels wrong"

example

9.87 fmod 1 = 0.87
9.87 fmod 2 = 1.87

Yes.. i can code something like that myself ... but for i am looking for an INTERNAL function that does this... something that would also please me would be Fx(9.87) = 0.87

The "normal" mod and \ only return integers but i also need to "keep" the real part of my numbers...

0
rdrunner
1 Solution

Billing EngineerCommented:
no, VB doesn't have that.

9.87 fmod 1 ---> 9.87 - cint(9.87)

Thus, the function would be

Public Function fmod( v as double , m as long) as double
fmod = cint(v) - 1 + m
End Function
0

Associate Director - Product EngineeringCommented:
0

Author Commented:
Thanks for both tries ;)

- Angelll thats (kinda) how i currently do it myself ;)
I said i dont want to write a function but i am looking for the internal ones that acomplish those functions...

And your function should be something like :

Public Function fMod(nNumber As Double, nDiv As Double) As Double
Dim nTmp As Double
nTmp = nNumber / nDiv
nTmp = (nTmp - CInt(nTmp))
If nTmp < 1 Then nTmp = nTmp + 1
fMod = nTmp * nDiv
End Function

- Mayankaeagle : Thats VB.NET - I was looking for vb6

0

Commented: