Results 1 to 10 of 10

Division by zero

Threaded View

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    Monterrey, México
    MS-Off Ver
    MAC 2011
    Posts
    6

    Division by zero

    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
    Last edited by raulge91; 07-21-2015 at 06:47 PM. Reason: Noob

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. #DIV/0! without any division!!!
    By JudiK in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-04-2013, 08:43 PM
  2. division gives wrong answer (division)
    By Brice in forum Excel General
    Replies: 5
    Last Post: 12-24-2010, 10:13 PM
  3. Division
    By samjs in forum Excel General
    Replies: 3
    Last Post: 02-22-2010, 02:01 AM
  4. Help with division
    By Twyko in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-11-2009, 04:48 PM
  5. Division by Zero
    By scotfitz in forum Excel General
    Replies: 5
    Last Post: 06-15-2008, 06:20 PM
  6. Need help with division, please!!!
    By swag143 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2006, 12:05 PM
  7. [SOLVED] Division
    By David in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-26-2006, 06:05 AM
  8. Division By Zero
    By carl in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-27-2005, 01:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1