Sup,
I have a problem in this code:
ReDim SMT(1 To Per) As Variant
Dim cont As Integer
cont = 1
For i = 1 To segmentos
For j = 1 To PS(i)
If s(i) = 1 Then SMT(cont) = salario_inicial(i) / 70.1 / 30.4
If s(i) = 2 Then SMT(cont) = ((salario_inicial(i) - salario_final(i)) / ((PS(i) - j) + salario_final(i))) / 30.4 / 70.1
'Para este caso se traslada el Punto de Origen a: [PS(i-1), salario_final(i)]
If s(i) = 3 Then
If j = 1 Then
SMT(cont) = salario_inicial(i) / 30.4 / 70.1
Else
H = PS(i)
k = (salario_final(i))
a = (-H / ((SMT(cont - 1) * 30.4 * 70.1) - k) ^ 2)
fga = 1
fgb = -2 * k
fgc = k ^ 2 + (H - j) / a
SMTP = (-fgb + ((fgb) ^ 2 - 4 * fga * fgc) ^ 0.5) / 2
SMTN = (-fgb - ((fgb) ^ 2 - 4 * fga * fgc) ^ 0.5) / 2
If Round(SMTP, 2) > Round(SMTN, 2) Then
SMT(cont) = SMTP / 30.4 / 70.1
Else
SMT(cont) = SMTN / 30.4 / 70.1
End If
End If
End If
cont = cont + 1
Next j
Next i
It returns values from the general equation formula, but when the inner loop is finished once, it says that there is a division by zero and the program highlights the j variable. Using the watch feature, I get j's value as 2.
Any help will be really grateful.
Thanks
Bookmarks