PDA

Click to See Complete Forum and Search --> : Cast from string "15726451-1364743165280" to type 'Double' is not valid.


Lord_Rat
Mar 12th, 2003, 02:16 AM
Given:

Try
Dim t As String = e.Item.Cells(3).Text
Response.Write("<h4>" & t & "</h4>")
Dim dd As Double = Double.Parse(t)
'Response.Write(e.Item.Cells(3).Text)
If dd < 0.1 Then
e.Item.Cells(0).BackColor = System.Drawing.Color.FromArgb(&HD1, &H3D, &H47) 'red
ElseIf dd > 100 Then
e.Item.Cells(0).BackColor = System.Drawing.Color.FromArgb(&H81, &HB4, &H4B) 'green
Else
Response.Write(ColorFade(&HEFF773, &HD13D47, dd).ToString & " Color Faded from " & e.Item.Cells(3).Text.ToString() & "<hr>")
e.Item.Cells(0).BackColor = System.Drawing.Color.FromArgb(ColorFade(&HEFF773, &HD13D47, dd))
End If
Catch ee As Exception
Dim i As Integer
For i = 0 To e.Item.Cells.Count - 1
Response.Write(e.Item.Cells(i).Text & " : ")
Next
Response.Write(":No Decimal conversion " & e.Item.Cells(3).Text & ":" & ee.Message & "<br>")
End Try


If e.item.cells(3) is within the range of .99999999 to -.9999999, then the error 'Cast from string "15726451-1364743165280" to type 'Double' is not valid' occurs. I DID NOT attempt to double.parse a string of "15726451-1364743165280"!!

Why is this occurring:

Page output using above code:

0.502680311890838
: : 275 : 0.502680311890838 : 100 : UNASSIGNED : UNASSIGNED : : TS : Outbound : : : : : 6 : : 3 : : :No Decimal conversion 0.502680311890838:Cast from string "15726451-1364743165280" to type 'Double' is not valid.

0.807479804907788
: : 591 : 0.807479804907788 : 100 : UNASSIGNED : UNASSIGNED : : TS : Outbound : : : : : 6 : : 3 : : :No Decimal conversion 0.807479804907788:Cast from string "15726451-1364743165280" to type 'Double' is not valid.

Lord_Rat
Mar 12th, 2003, 02:17 AM
Please note that values >= 1 or <= -1 will convert without a hitch.