I have below a small function that generates a 4 diget code from the
square root of the date.
Public Function Generate() As String
Dim n As Integer
Dim s As String = Today.ToString("ddMMyyyy")
n = Integer.Parse(s)
n = CInt(Math.Sqrt(n))
Return n.ToString("0000")
End Function
How ever when i have a day that has a decimal place higher than 5 the
last number is rounded up.
Example:
square root of the 12/03/2007 is 3468.7183512069699314940377884052
however using the above function it returns 3469
Anyone know how i can stop this rounding and just to read the 1st for
numbers?
Thanks in advance,
Andy
Use the Visual Basic functions Int or Fix instead of CInt. Or use the Math
class's Floor method.
Kerry Moorman
Using just an int seemed to fix that problem.
Andy