none
Stack over flow exception (make sure that, you don't have infinite loop or infinite recursion RRS feed

  • Question

  • Hi,

    I get massage of over flow exception (make sure that you don't have infinite loop or infinite recursion.

    The program during run does not go to the content of private sub, I don't know the mistake.

    Please advice how to solve this problem.

     


    Hany Metry

    Friday, June 19, 2020 7:58 AM

Answers

  • Hi All,

    After divide the Sub into two subs (the first one have 3 loops and the second one have two loops), the problem is solved.

    Conclusion

    Long sub may provide over flow exception.

    Kind Regards,

    Hany Sabry


    Hany Metry

    • Marked as answer by Hany Metry Saturday, June 20, 2020 11:32 AM
    Saturday, June 20, 2020 11:31 AM

All replies

  • Hi

    As you say you don't use the Sub, then just delete it!


    Regards Les, Livingston, Scotland


    • Edited by leshay Friday, June 19, 2020 10:55 AM
    Friday, June 19, 2020 10:54 AM
  • Hi,

    There are 5 loops as shown in the code below,

    For I As Integer = 1 To 99
                    X = 0.01 * S * I
                    X2 = 0.01 * S + 0.01 * S * I
    
    If (Qzero1 >= 0.0 And Qzero2 <= 0.0) Then
                        GoTo 7899
                    End If
                Next
    7899:       If Mmax2 >= Mmax1 Then
                    Mmaxu = Mmax2
                    Xfu = X2
                Else
                    Mmaxu = Mmax1
                    Xfu = X
                End If

    Kind Regards,


    Hany Metry


    • Edited by Hany Metry Friday, June 19, 2020 1:52 PM
    Friday, June 19, 2020 1:51 PM
  • Hi

    Probably the cause of your problem, Why are you using GoTo? Are you trying to use VB6 in VB.NET?


    Regards Les, Livingston, Scotland

    Friday, June 19, 2020 1:57 PM
  • Hi

    Probably the cause of your problem, Why are you using GoTo? Are you trying to use VB6 in VB.NET?


    Regards Les, Livingston, Scotland

    Hi,

    I use Goto many times before and without any problem.

    I think that is not a problem.

    Kind Regards,


    Hany Metry

    Friday, June 19, 2020 2:04 PM
  • You could try the methods discussed in https://stackoverflow.com/questions/4733878/how-to-debug-a-stackoverflowexception-in-net

    Hi,

    How to find the installation requirements for window 7 Ultimate 64 bit, and Visual studio 2013

    https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

    Kind Regards,


    Hany Metry

    Saturday, June 20, 2020 2:22 AM
  • Hi,

    Really I installed WDK but I don't know how to debug and solve the problem.

    Kind Regards,


    Hany Metry

    Saturday, June 20, 2020 3:04 AM
  • Hi,

    Below is one of the five loop code.

    Can I have an assist for that.

    For I As Integer = 1 To 99
                    X = 0.01 * S * I
                    X2 = 0.01 * S + 0.01 * S * I
                    If a1d <> "" And a2d <> "" And a3d <> "" And a4d <> "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000 + (CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) * (2 * (S - CDbl(a2d)) + (CDbl(a2d) - CDbl(a1d))) / (2 * S)) + (CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) * (2 * (S - CDbl(a4d)) + (CDbl(a4d) - CDbl(a3d))) / (2 * S))
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 + CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) + CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) - Rleft
                        If X <= d1d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) And X <= CDbl(a3d) Then
                                Qzero1 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X >= CDbl(a4d) Then
                                Qzero1 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X > d1d And X <= d2d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) And X <= CDbl(a3d) Then
                                Qzero1 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X >= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X > d2d And X <= d3d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) And X <= CDbl(a3d) Then
                                Qzero1 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X >= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X > d3d And X <= d4d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) And X <= CDbl(a3d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X >= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X > d4d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) And X <= CDbl(a3d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X >= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X) ^ 2 / (1000 * 2000)
                            End If
                        End If
                    ElseIf a1d <> "" And a2d <> "" And a3d = "" And a4d = "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000 + (CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) * (2 * (S - CDbl(a2d)) + (CDbl(a2d) - CDbl(a1d))) / (2 * S))
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 + CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) - Rleft
                        If X <= d1d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) Then
                                Qzero1 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d1d And X <= d2d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d2d And X <= d3d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d3d And X <= d4d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d4d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a1d) And X <= CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (X - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (X - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a2d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        End If
                    ElseIf a1d = "" And a2d = "" And a3d <> "" And a4d <> "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000 + (CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) * (2 * (S - CDbl(a4d)) + (CDbl(a4d) - CDbl(a3d))) / (2 * S))
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 + CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) - Rleft
                        If X <= d1d Then
                            If X <= CDbl(a3d) Then
                                Qzero1 = Rleft - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - (X - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (X - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a4d) Then
                                Qzero1 = Rleft - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d1d And X <= d2d Then
                            If X <= CDbl(a3d) Then
                                Qzero1 = Rleft - P1d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - (X - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (X - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d2d And X <= d3d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - (X - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (X - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d3d And X <= d4d Then
                            If X <= CDbl(a3d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (X - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (X - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X > d4d Then
                            If X <= CDbl(a1d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a3d) And X <= CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (X - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (X - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            ElseIf X > CDbl(a4d) Then
                                Qzero1 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X / 1000
                                Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X) ^ 2 / (2000 * 1000)
                            End If
                        End If
                    ElseIf a1d = "" And a2d = "" And a3d = "" And a4d = "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 - Rleft
                        If X <= d1d Then
                            Qzero1 = Rleft - wund * X / 1000
                            Mmax1 = Rleft * X / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                        ElseIf X > d1d And X <= d2d Then
                            Qzero1 = Rleft - P1d - wund * X / 1000
                            Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                        ElseIf X > d2d And X <= d3d Then
                            Qzero1 = Rleft - P1d - P2d - wund * X / 1000
                            Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                        ElseIf X > d3d And X <= d4d Then
                            Qzero1 = Rleft - P1d - P2d - P3d - wund * X / 1000
                            Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                        ElseIf X > d4d Then
                            Qzero1 = Rleft - P1d - P2d - P3d - P4d - wund * X / 1000
                            Mmax1 = Rleft * X / 1000 - P1d * (X - d1d) / 1000 - P2d * (X - d2d) / 1000 - P3d * (X - d3d) / 1000 - P4d * (X - d4d) / 1000 - wund * (X) ^ 2 / (2000 * 1000)
                        End If
                    End If
                    If a1d <> "" And a2d <> "" And a3d <> "" And a4d <> "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000 + (CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) * (2 * (S - CDbl(a2d)) + (CDbl(a2d) - CDbl(a1d))) / (2 * S)) + (CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) * (2 * (S - CDbl(a4d)) + (CDbl(a4d) - CDbl(a3d))) / (2 * S))
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 + CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) + CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) - Rleft
                        If X2 <= d1d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) And X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X2 - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X2 - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 >= CDbl(a4d) Then
                                Qzero2 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X2) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X2 > d1d And X2 <= d2d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) And X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X2 - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X2 - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 >= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X2) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X2 > d2d And X2 <= d3d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) And X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X2 - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X2 - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 >= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X2) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X2 > d3d And X2 <= d4d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) And X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X2 - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X2 - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 >= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X2) ^ 2 / (1000 * 2000)
                            End If
                        ElseIf X2 > d4d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) And X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (X2 - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (X2 - CDbl(a3d)) ^ 2 * CDbl(w3d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 >= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * CDbl(w3d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w3d) / (1000 * 1000) - wund * (X2) ^ 2 / (1000 * 2000)
                            End If
                        End If
                    ElseIf a1d <> "" And a2d <> "" And a3d = "" And a4d = "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000 + (CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) * (2 * (S - CDbl(a2d)) + (CDbl(a2d) - CDbl(a1d))) / (2 * S))
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 + CDbl(w1d) * (CDbl(a2d) / 1000 - CDbl(a1d) / 1000) - Rleft
                        If X2 <= d1d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) Then
                                Qzero2 = Rleft - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d1d And X2 <= d2d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d2d And X2 <= d3d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d3d And X2 <= d4d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d4d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a1d) And X2 <= CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (X2 - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (X2 - CDbl(a1d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a2d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a2d) - CDbl(a1d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (CDbl(a2d) - CDbl(a1d)) * (X2 - (CDbl(a2d) + CDbl(a1d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        End If
                    ElseIf a1d = "" And a2d = "" And a3d <> "" And a4d <> "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000 + (CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) * (2 * (S - CDbl(a4d)) + (CDbl(a4d) - CDbl(a3d))) / (2 * S))
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 + CDbl(w3d) * (CDbl(a4d) / 1000 - CDbl(a3d) / 1000) - Rleft
                        If X2 <= d1d Then
                            If X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - (X2 - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (X2 - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a4d) Then
                                Qzero2 = Rleft - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d1d And X2 <= d2d Then
                            If X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - P1d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - (X2 - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (X2 - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d2d And X2 <= d3d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - (X2 - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (X2 - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d3d And X2 <= d4d Then
                            If X2 <= CDbl(a3d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (X2 - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (X2 - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        ElseIf X2 > d4d Then
                            If X2 <= CDbl(a1d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a3d) And X2 <= CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (X2 - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (X2 - CDbl(a3d)) ^ 2 * CDbl(w1d) / (2000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            ElseIf X2 > CDbl(a4d) Then
                                Qzero2 = Rleft - P1d - P2d - P3d - P4d - (CDbl(a4d) - CDbl(a3d)) * CDbl(w1d) / 1000 - wund * X2 / 1000
                                Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - (CDbl(a4d) - CDbl(a3d)) * (X2 - (CDbl(a4d) + CDbl(a3d)) / 2) * CDbl(w1d) / (1000 * 1000) - wund * (X2) ^ 2 / (2000 * 1000)
                            End If
                        End If
                    ElseIf a1d = "" And a2d = "" And a3d = "" And a4d = "" Then
                        Rleft = P1d * (S - d1d) / S + P2d * (S - d2d) / S + P3d * (S - d3d) / S + P4d * (S - d4d) / S + wund * S / 2000
                        Rright = P1d + P2d + P3d + P4d + wund * S / 1000 - Rleft
                        If X2 <= d1d Then
                            Qzero2 = Rleft - wund * X2 / 1000
                            Mmax2 = Rleft * X2 / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                        ElseIf X2 > d1d And X2 <= d2d Then
                            Qzero2 = Rleft - P1d - wund * X2 / 1000
                            Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                        ElseIf X2 > d2d And X2 <= d3d Then
                            Qzero2 = Rleft - P1d - P2d - wund * X2 / 1000
                            Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                        ElseIf X2 > d3d And X2 <= d4d Then
                            Qzero2 = Rleft - P1d - P2d - P3d - wund * X2 / 1000
                            Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                        ElseIf X2 > d4d Then
                            Qzero2 = Rleft - P1d - P2d - P3d - P4d - wund * X2 / 1000
                            Mmax2 = Rleft * X2 / 1000 - P1d * (X2 - d1d) / 1000 - P2d * (X2 - d2d) / 1000 - P3d * (X2 - d3d) / 1000 - P4d * (X2 - d4d) / 1000 - wund * (X2) ^ 2 / (2000 * 1000)
                        End If
                    End If
                    If (Qzero1 >= 0.0 And Qzero2 <= 0.0) Then
                        GoTo 789
                    End If
                Next
    789:        If Mmax2 >= Mmax1 Then
                    Mmax = Mmax2
                    Xf = X2
                Else
                    Mmax = Mmax1
                    Xf = X
                End If


    Hany Metry

    Saturday, June 20, 2020 4:52 AM
  • When you start the program in Debug mode and the program stops at mentioned exception, try investigating the Call Stack details (from menu, Debug, Windows, Call Stack). In case of recursions, it will display the callers.

    Show some details about Call Stack.

    Saturday, June 20, 2020 8:48 AM
  • Hi All,

    I don't know how to debug the over flow exception?

    I tried to comment some lines and run only some lines of the private sub, I find there is no problem and the program executed.

    I remove the some comments and the program is also run without any problem.

    After remove all the comments the program don't run and have over flow exception.

    I don't know where the problem, maybe the memory of my computer have a problem or I don't know.

    Really there is no mistake but still the program not run and have over flow exception (infinite loop).

    Kind Regards,


    Hany Metry


    • Edited by Hany Metry Friday, July 3, 2020 2:40 AM adjust
    Saturday, June 20, 2020 10:59 AM
  • Hi All,

    After divide the Sub into two subs (the first one have 3 loops and the second one have two loops), the problem is solved.

    Conclusion

    Long sub may provide over flow exception.

    Kind Regards,

    Hany Sabry


    Hany Metry

    • Marked as answer by Hany Metry Saturday, June 20, 2020 11:32 AM
    Saturday, June 20, 2020 11:31 AM