Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Calculate_Click()
- If Ptext.Text = "" Then
- MsgBox ("Please enter the principle!")
- GoTo skip
- Else
- End If
- If Rtext.Text = "" Then
- MsgBox ("Please enter the rate!")
- GoTo skip
- Else
- End If
- If Choice.Text = "" Then
- MsgBox ("Please select a compounding rate!")
- GoTo skip
- Else
- End If
- If Syear.Text = "" Then
- MsgBox ("Please select the starting date!")
- GoTo skip
- Else
- End If
- If Fyear.Text = "" Then
- MsgBox ("Please select the end date!")
- GoTo skip
- Else
- End If
- Dim a As Integer
- a = CInt(Syear)
- Dim b As Integer
- b = CInt(Smonth)
- Dim c As Integer
- c = CInt(Sweek)
- Dim d As Integer
- d = CInt(Fyear)
- Dim e As Integer
- e = CInt(Fmonth)
- Dim f As Integer
- f = CInt(Fweek)
- If a = d Then
- Dim z As Integer
- z = 0
- GoTo month
- Else
- End If
- z = d - a
- month:
- If b = e Then
- GoTo week
- Else
- End If
- Dim y As Integer
- y = e - b
- If y < 0 Then
- If z = 0 Then
- Else
- z = z - 1
- y = 12 - (y * -1)
- End If
- Else
- End If
- week:
- Dim x As Integer
- If c = f Then
- If z = 0 Then
- MsgBox ("Please enter a time period of greater than or equal to one week!")
- Exit Sub
- Else
- End If
- Else
- End If
- x = f - c
- If x < 0 Then
- x = 52 - (x * -1)
- Else
- End If
- If Choice.Text = "1" Then
- If z = 0 Then
- MsgBox ("Please enter enough a minimum of 1 year for annual compounding!")
- Exit Sub
- Else
- End If
- Dim g As Double
- g = CDbl(Ptext)
- Dim h As Double
- h = CDbl(Rtext)
- Dim w As Double
- w = g * (((1 + h) ^ z - 1) / h)
- Result.Caption = Round(w, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- GoTo skip
- Else
- End If
- Dim i As Double
- i = CDbl(Ptext)
- Dim j As Double
- j = CDbl(Rtext)
- Dim v As Double
- If Choice.Text = "2" Then
- If z = 0 Then
- v = i * (((1 + j / y) ^ (y * z) - 1) / j / 12) + i * (((1 + (j / (12))) ^ (12 * y) / j / 12))
- Result.Caption = Round(v, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- GoTo skip
- Else
- If y = 0 Then
- v = i * (((1 + j) ^ (z) - 1) / j) + i * (((1 + (j / (12 * z))) ^ (12 * z) / j))
- Result.Caption = Round(v, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- GoTo skip
- Else
- v = i * (((1 + j / y) ^ (y * z) - 1) / j) + i * (((1 + (j / (12 * z))) ^ (12 * z * y) / j))
- Result.Caption = Round(v, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- GoTo skip
- End If
- End If
- Else
- End If
- If Choice.Text = "3" Then
- Dim k As Double
- k = CDbl(Ptext)
- Dim l As Double
- l = CDbl(Rtext)
- Dim u As Double
- If z = 0 Then
- u = k * ((1 + l / 52) ^ 52 - 1 / l / 52)
- Result.Caption = Round(u, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- GoTo skip
- Else
- End If
- If y = 0 Then
- u = k * (((1 + l / 52) ^ (52 * z) - 1) / (l / 52))
- Result.Caption = Round(u, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- GoTo skip
- Else
- End If
- u = k * (((1 + l / 52) ^ (52 * z) - 1) / (l / 52))
- Result.Caption = Round(u, 2)
- Result.Visible = True
- Money.Visible = True
- Total.Visible = True
- Else
- End If
- skip:
- End Sub
- Private Sub Clear_Click()
- Dim continue As String
- continue = MsgBox("Are you sure you want to clear all fields?", vbYesNo + vbQuestion, "Clear")
- If continue = vbYes Then
- Ptext.Text = ""
- Rtext.Text = ""
- Annually.Value = False
- Monthly.Value = False
- Weekly.Value = False
- Total.Visible = False
- Money.Visible = False
- Result.Visible = False
- Result.Caption = ""
- Choice.Text = ""
- Syear.Text = ""
- Smonth.Text = ""
- Sweek.Text = ""
- Fyear.Text = ""
- Fmonth.Text = ""
- Fweek.Text = ""
- Else
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement