Advertisement
Guest User

ermahgerd

a guest
Aug 29th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub Calculate_Click()
  2. If Ptext.Text = "" Then
  3. MsgBox ("Please enter the principle!")
  4. GoTo skip
  5. Else
  6. End If
  7. If Rtext.Text = "" Then
  8. MsgBox ("Please enter the rate!")
  9. GoTo skip
  10. Else
  11. End If
  12. If Choice.Text = "" Then
  13. MsgBox ("Please select a compounding rate!")
  14. GoTo skip
  15. Else
  16. End If
  17. If Syear.Text = "" Then
  18. MsgBox ("Please select the starting date!")
  19. GoTo skip
  20. Else
  21. End If
  22. If Fyear.Text = "" Then
  23. MsgBox ("Please select the end date!")
  24. GoTo skip
  25. Else
  26. End If
  27. Dim a As Integer
  28. a = CInt(Syear)
  29. Dim b As Integer
  30. b = CInt(Smonth)
  31. Dim c As Integer
  32. c = CInt(Sweek)
  33. Dim d As Integer
  34. d = CInt(Fyear)
  35. Dim e As Integer
  36. e = CInt(Fmonth)
  37. Dim f As Integer
  38. f = CInt(Fweek)
  39. If a = d Then
  40. Dim z As Integer
  41. z = 0
  42. GoTo month
  43. Else
  44. End If
  45. z = d - a
  46. month:
  47. If b = e Then
  48. GoTo week
  49. Else
  50. End If
  51. Dim y As Integer
  52. y = e - b
  53. If y < 0 Then
  54. If z = 0 Then
  55. Else
  56. z = z - 1
  57. y = 12 - (y * -1)
  58. End If
  59. Else
  60. End If
  61. week:
  62. Dim x As Integer
  63. If c = f Then
  64. If z = 0 Then
  65. MsgBox ("Please enter a time period of greater than or equal to one week!")
  66. Exit Sub
  67. Else
  68. End If
  69. Else
  70. End If
  71. x = f - c
  72. If x < 0 Then
  73. x = 52 - (x * -1)
  74. Else
  75. End If
  76. If Choice.Text = "1" Then
  77. If z = 0 Then
  78. MsgBox ("Please enter enough a minimum of 1 year for annual compounding!")
  79. Exit Sub
  80. Else
  81. End If
  82. Dim g As Double
  83. g = CDbl(Ptext)
  84. Dim h As Double
  85. h = CDbl(Rtext)
  86. Dim w As Double
  87. w = g * (((1 + h) ^ z - 1) / h)
  88. Result.Caption = Round(w, 2)
  89. Result.Visible = True
  90. Money.Visible = True
  91. Total.Visible = True
  92. GoTo skip
  93. Else
  94. End If
  95. Dim i As Double
  96. i = CDbl(Ptext)
  97. Dim j As Double
  98. j = CDbl(Rtext)
  99. Dim v As Double
  100. If Choice.Text = "2" Then
  101. If z = 0 Then
  102. v = i * (((1 + j / y) ^ (y * z) - 1) / j / 12) + i * (((1 + (j / (12))) ^ (12 * y) / j / 12))
  103. Result.Caption = Round(v, 2)
  104. Result.Visible = True
  105. Money.Visible = True
  106. Total.Visible = True
  107. GoTo skip
  108. Else
  109. If y = 0 Then
  110. v = i * (((1 + j) ^ (z) - 1) / j) + i * (((1 + (j / (12 * z))) ^ (12 * z) / j))
  111. Result.Caption = Round(v, 2)
  112. Result.Visible = True
  113. Money.Visible = True
  114. Total.Visible = True
  115. GoTo skip
  116. Else
  117. v = i * (((1 + j / y) ^ (y * z) - 1) / j) + i * (((1 + (j / (12 * z))) ^ (12 * z * y) / j))
  118. Result.Caption = Round(v, 2)
  119. Result.Visible = True
  120. Money.Visible = True
  121. Total.Visible = True
  122. GoTo skip
  123. End If
  124. End If
  125. Else
  126. End If
  127. If Choice.Text = "3" Then
  128. Dim k As Double
  129. k = CDbl(Ptext)
  130. Dim l As Double
  131. l = CDbl(Rtext)
  132. Dim u As Double
  133. If z = 0 Then
  134. u = k * ((1 + l / 52) ^ 52 - 1 / l / 52)
  135. Result.Caption = Round(u, 2)
  136. Result.Visible = True
  137. Money.Visible = True
  138. Total.Visible = True
  139. GoTo skip
  140. Else
  141. End If
  142. If y = 0 Then
  143. u = k * (((1 + l / 52) ^ (52 * z) - 1) / (l / 52))
  144. Result.Caption = Round(u, 2)
  145. Result.Visible = True
  146. Money.Visible = True
  147. Total.Visible = True
  148. GoTo skip
  149. Else
  150. End If
  151. u = k * (((1 + l / 52) ^ (52 * z) - 1) / (l / 52))
  152. Result.Caption = Round(u, 2)
  153. Result.Visible = True
  154. Money.Visible = True
  155. Total.Visible = True
  156. Else
  157. End If
  158. skip:
  159. End Sub
  160.  
  161. Private Sub Clear_Click()
  162. Dim continue As String
  163. continue = MsgBox("Are you sure you want to clear all fields?", vbYesNo + vbQuestion, "Clear")
  164. If continue = vbYes Then
  165. Ptext.Text = ""
  166. Rtext.Text = ""
  167. Annually.Value = False
  168. Monthly.Value = False
  169. Weekly.Value = False
  170. Total.Visible = False
  171. Money.Visible = False
  172. Result.Visible = False
  173. Result.Caption = ""
  174. Choice.Text = ""
  175. Syear.Text = ""
  176. Smonth.Text = ""
  177. Sweek.Text = ""
  178. Fyear.Text = ""
  179. Fmonth.Text = ""
  180. Fweek.Text = ""
  181. Else
  182. End If
  183. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement