Start New Discussion within our Software Development Community

am trying to calculate the values in rows in column 6 based on values of column 5. Bellow is the the code I am using
Can anyone help me getting it right?
I get a run time error about the string not formatted properly
Thanks in advance

Public Sub DataGridView1_CellValidated()


        'Dim Result As Int32 = 0
        'For Each r As DataGridViewRow In Me.DataGridView1.Rows
        '    Result = Result + r.Cells(5).Value * r.Cells(3).Value
        '    r.Cells(1).Value = Result
        'Next
        Dim result As Double = 0
        Dim i As Integer = 0
        For i = 0 To DataGridView1.Rows.Count - 1
            If (DataGridView1.Rows(i).Cells(5).Value) = "" Then
                MsgBox("nothing to do")
            Else


                Convert.ToDouble(DataGridView1.Rows(i).Cells(5).Value)
                result = Convert.ToDouble(DataGridView1.Rows(i).Cells(6).Value)
                'With row(i).Cells(5).Value
                'Select Case row.Cells(5).Value
                ''Case Is >= 1.1
                'Result = "#+"
                If DataGridView1.Rows(i).Cells(5).Value >= 1.1 Then
                    result = "#+"
                End If

                '    Case Is <= 0.9
                'Result = "#-"
                If DataGridView1.Rows(i).Cells(5).Value <= 0.9 Then
                    result = "#-"
                End If
                '    Case Is = 0.9 And 1.1
                'Result = "#eq"
                If DataGridView1.Rows(i).Cells(5).Value >= 0.9 And _
                    DataGridView1.Rows(i).Cells(5).Value <= 1.1 Then
                    result = "#eq"
                End If
                '    Case Else
                'Result = "Error"
                'End Select
                'End With
            End If
        Next i
        'Next


    End Sub
This article has been dead for over six months. Start a new discussion instead.