0
Reply

invalid cast exception

ewarmour

ewarmour

May 6 2004 11:50 AM
1.5k
Hi all, I have a function to calculate the area of a rectangle like so: Public Shared Function Area(ByVal ptdWidth1 As PointD, ByVal ptdWidth2 As PointD, ByVal ptdHeight1 As PointD, ByVal ptdHeight2 As PointD) As Double Dim dblWidth As Double = ptdWidth2.X - ptdWidth1.X Dim dblHeight As Double = ptdHeight1.Y - ptdHeight2.Y Return (dblWidth * dblHeight) End Function When I call it and try to write the result to a textbox on my windows form Like so: txtRectResult.Text = String.Format("{0:F}", Geometry.Rectangle.Area(ptdTopLeft.X, ptdTopLeft.Y, ptdBottomRight.X, ptdBottomRight.Y)) I get an invalid cast exception. Can anyone tell me why? Thanks -E