Results 1 to 2 of 2

Thread: Cast from string "15726451-1364743165280" to type 'Double' is not valid.

  1. #1

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Cast from string "15726451-1364743165280" to type 'Double' is not valid.

    Given:
    VB Code:
    1. Try
    2.                     Dim t As String = e.Item.Cells(3).Text
    3.                     Response.Write("<h4>" & t & "</h4>")
    4.                     Dim dd As Double = Double.Parse(t)
    5.                     'Response.Write(e.Item.Cells(3).Text)
    6.                     If dd < 0.1 Then
    7.                         e.Item.Cells(0).BackColor = System.Drawing.Color.FromArgb(&HD1, &H3D, &H47)                      'red
    8.                     ElseIf dd > 100 Then
    9.                         e.Item.Cells(0).BackColor = System.Drawing.Color.FromArgb(&H81, &HB4, &H4B)                      'green
    10.                     Else
    11.                         Response.Write(ColorFade(&HEFF773, &HD13D47, dd).ToString & " Color Faded from " & e.Item.Cells(3).Text.ToString() & "<hr>")
    12.                         e.Item.Cells(0).BackColor = System.Drawing.Color.FromArgb(ColorFade(&HEFF773, &HD13D47, dd))
    13.                     End If
    14.                 Catch ee As Exception
    15.                     Dim i As Integer
    16.                     For i = 0 To e.Item.Cells.Count - 1
    17.                         Response.Write(e.Item.Cells(i).Text & " : ")
    18.                     Next
    19.                     Response.Write(":No Decimal conversion " & e.Item.Cells(3).Text & ":" & ee.Message & "<br>")
    20.                 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.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  2. #2

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Please note that values >= 1 or <= -1 will convert without a hitch.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width