Private Sub DataGridView1_RowValidating(sender As Object, e As DataGridViewCellCancelEventArgs) Handles DataGridView1.RowValidating
Dim transferredQTY, onHandQTY As Double
With DataGridView1.Rows(e.RowIndex)
Try
transferredQTY = Convert.ToDouble(.Cells(2).Value)
Catch ex As Exception
transferredQTY = 0
End Try
Try
onHandQTY = Convert.ToDouble(.Cells(1).Value)
Catch ex As Exception
transferredQTY = 0
End Try
If transferredQTY > onHandQTY Then
MessageBox.Show("You don't Have sufficient quantity ", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
e.Cancel = True
End If
End With
End Sub