rdrunner
asked on
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...
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
- 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
Angel correctly answered your question in that case. The answer is no. ;)
ASKER
Ok then ;)
My "math english" isnt the best so i thought i just was unable to translate it correctly ;)
My "math english" isnt the best so i thought i just was unable to translate it correctly ;)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfvbspec11_5_5.asp
See if it helps!
Mayank.