2017-10-05 9 views
0

datagridviewの次の行が負に等しいかどうかを判断する方法についてこの問題が発生した場合、現在の行は備考を返します。datagridviewの次の行が負の整数に等しいかどうかを調べるにはどうすればよいですか?

たとえば、

Remarks Reference 
    A   1 
    A   2 
    B   3 
      -4 

次の行が正の数であれば、発言はA.され、次の行が負の値であれば、発言は、私がこの部分で苦労B.

を返します。ここで

はコードです:

For Each r As DataGridViewRow In dgvSTSub.Rows 
     Bal = Bal + r.Cells(3).Value - r.Cells(1).Value 
     r.Cells(3).Value = Bal 

     If Bal > Bal + r.Cells(3).Value Then 
      r.Cells(2).Value = r.Cells(1).Value 
     End If 
    Next 

上記のように、実際のDataGridViewではなかったが、それは私が起こるしたいものです。

ご協力いただきありがとうございます。

+0

であなたの闘争をご提示くださいこの部分 – Plutonix

+0

こんにちは私のコードを含めることができませんでした。 – Diaval

+0

私の投稿を編集しました。どうぞご覧ください。 – Diaval

答えて

0

与えられたデータから。備考cells(0)にあり、リファレンスcells(1)から負の整数を決定するにはcells(1)
である:

参照は整数のみが含まれていることを仮定すると:(これらのコードを使用します)

Dim i As Integer = 0 
    Dim number As Integer 
    While i <= DataGridView1.RowCount - 1 
     number = CInt(DataGridView1.Rows(i).Cells(1).Value) 
     If number < 0 Then 
      MsgBox("Row: " & i & " is Negative number") ' Omit this line if you want. 
      ' Add your codes here 
     End If 
     i += 1 
    End While 
関連する問題