M
mp
what's the diff between cType(x,y) and DirectCast(x,y)?
they appear to do the same thing
thanks
mark
they appear to do the same thing
thanks
mark
what's the diff between cType(x,y) and DirectCast(x,y)?
they appear to do the same thing
thanks again!
I just discovered the cType function by discovering the suggested fixes for
syntax errors the ide provided when i converted a project from Option strict
off to option strict on, and fixing the many errors discovered.
I'll play with that soon to see if ctype(3.14, integer) is like int(3.14) or
fix(3.14) - truncate or round.
anyway thanks again for the info.
As to the differences, try this:
Armin Zingler said:Am 12.07.2010 16:21, schrieb Armin Zingler:
New version. Including rounding "away from zero".
Public Class Main
Shared Sub Main()
Const fmt As String = "{0,10} {1,15} {2,10} {3,10} {4,10} {5,10}
{6,10}"
Debug.Print(fmt, "value", "Math.Floor", "Int", "Fix", "Cint",
"Round", "Round (afz)")
For i = -40 To 40
Dim d = i / 10
Dim o1 = Math.Floor(d)
Dim o2 = Int(d)
Dim o3 = Fix(d)
Dim o4 = CInt(d)
Dim o5 = Math.Round(d)
Dim o6 = Math.Round(d, MidpointRounding.AwayFromZero)
Debug.Print(fmt, d, o1, o2, o3, o4, o5, o6)
Next
End Sub
End Class