Please help me. I am trying to make a program using loops. What the program is meant to do is give me the amount of days when the Total2 > Total1. The restriction is that Total2 must be less then Total1. Also if the totals are over 1,000,000,000, the loop must end with a message showing that there has been a problem. This is what I have so far. Please help me.
[CODE=vbnet]Option Strict On
Option Explicit On
Public Class Form1
Dim Day As Double
Dim Total1 As Decimal
Dim Total2 As Decimal
Private Sub btnCalculate_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCalculate.Cl ick
Dim SingleAmount As Decimal
Dim DoubleAmount As Decimal
SingleAmount = CDec(txtSingleI nput.Text)
DoubleAmount = CDec(txtDoubleI nput.Text)
If Decimal.TryPars e(txtSingleInpu t.Text, CDec(SingleAmou nt)) = False Then
MessageBox.Show ("Please enter a numeric amount")
End If
If Decimal.TryPars e(txtDoubleInpu t.Text, CDec(DoubleAmou nt)) = False Then
MessageBox.Show ("Please enter a numeric Amount")
End If
Do Until Total1 < Total2
Day = Day + 1
Total1 = Total1 + SingleAmount
Total2 = Total2 + (DoubleAmount * 2)
If (Total1 > 1000000000) Or (Total2 > 1000000000) Then
MessageBox.Show ("The Values you have entered are invalid. Please re-enter.")
End
End If
Loop
Total1 = CDec(lblSingleO utput.Text)
Total2 = CDec(lblDoubleO utput.Text)
Day = CDbl(lblDays.Te xt)
End Sub
End Class[/CODE]
[CODE=vbnet]Option Strict On
Option Explicit On
Public Class Form1
Dim Day As Double
Dim Total1 As Decimal
Dim Total2 As Decimal
Private Sub btnCalculate_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCalculate.Cl ick
Dim SingleAmount As Decimal
Dim DoubleAmount As Decimal
SingleAmount = CDec(txtSingleI nput.Text)
DoubleAmount = CDec(txtDoubleI nput.Text)
If Decimal.TryPars e(txtSingleInpu t.Text, CDec(SingleAmou nt)) = False Then
MessageBox.Show ("Please enter a numeric amount")
End If
If Decimal.TryPars e(txtDoubleInpu t.Text, CDec(DoubleAmou nt)) = False Then
MessageBox.Show ("Please enter a numeric Amount")
End If
Do Until Total1 < Total2
Day = Day + 1
Total1 = Total1 + SingleAmount
Total2 = Total2 + (DoubleAmount * 2)
If (Total1 > 1000000000) Or (Total2 > 1000000000) Then
MessageBox.Show ("The Values you have entered are invalid. Please re-enter.")
End
End If
Loop
Total1 = CDec(lblSingleO utput.Text)
Total2 = CDec(lblDoubleO utput.Text)
Day = CDbl(lblDays.Te xt)
End Sub
End Class[/CODE]
Comment