'AQUI SE REALIZA LA CUENTA DEL IMPORTE TOTAL CUANDO EL TIPO DE PAGO ES 2 MENOS EL IMPORTE DE TIPO DE PAGO 1
Private Sub AjustarImporte2(ByVal cuentacuil As String)
Dim CuentaClientABuscar As String
Dim IndiceColumnaCuenta As Integer = 2
Dim IndiceColumnaTipoPago As Integer = 4 ' este variable no es utilizado en este ejemplo
Dim IndiceColumnaImporte As Integer = 5
Dim resul As Double
Dim Importe1 As Double
Dim Importe2 As Double
CuentaClientABuscar = cuentacuil
For L As Integer = 0 To DataGridView22.Rows.Count - 2 ' Escribir -1 si no existe una ultima linea vacia
If DataGridView22.Item(IndiceColumnaCuenta, L).Value = CuentaClientABuscar Then
Importe2 = CType(DataGridView22.Item(IndiceColumnaImporte, L).Value, Double)
If CType(DataGridView22.Item(IndiceColumnaTipoPago, L + 1).Value, Integer) = 1 Then
Importe1 = CType(DataGridView22.Item(IndiceColumnaImporte, L + 1).Value, Double)
resul = Importe2 - Importe1
DataGridView22.Item(IndiceColumnaImporte, L).Value = String.Format("{0:##0.00}", resul / 100).Replace(",", ".")
End If
Exit For
End If
Next
End Sub
'este es el codigo que llama a esa funcion
For Each item As DataGridViewRow In DataGridView22.Rows
If (item.Cells("CUENTAA").Value > 1 And item.Cells("TIPODEPAGO").Value = 1) - 1 Then
cuentacuil = item.Cells("CUENTAA").Value
AjustarImporte2(cuentacuil)
Else
SOLO_VALOR = 45
End If
Next