20-01-18, 09:28 PM
PHP كود :
Private Sub DataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If e.ColumnIndex = 1 Or e.ColumnIndex = 2 Or e.ColumnIndex = 3 Or e.ColumnIndex = 4 Then
If Not IsNothing(DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) Then
Dim b = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
If IsNumeric(b) Then
If b > 400 Or b < -400 Then
MsgBox("يرجى ادخال رقم بين 400 و -400")
DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 0
End If
Else
MsgBox("يرجى ادخال ارقام فقط")
DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 0
End If
End If
Calculate(e.RowIndex)
End If
End Sub
Sub Calculate(i As Integer)
Dim x As Double = Val(DataGridView1.Rows(i).Cells(1).Value)
Dim y As Double = Val(DataGridView1.Rows(i).Cells(2).Value)
Dim x2 As Double = Val(DataGridView1.Rows(i).Cells(3).Value)
Dim y2 As Double = Val(DataGridView1.Rows(i).Cells(4).Value)
Dim xx = x - x2
Dim yy = y - y2
DataGridView1.Rows(i).Cells(5).Value = ((xx ^ 2) + (yy ^ 2)) ^ (1 / 2)
End Sub
