Advertisement
jdelano

CodeBehind

Nov 26th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. Public Class _Default
  2. Inherits System.Web.UI.Page
  3.  
  4. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  5. If Not IsPostBack Then
  6.  
  7. End If
  8. End Sub
  9.  
  10. Protected Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
  11. Dim loanAmount As Double
  12. Dim interestRate As Double
  13. Dim loanTerm As Double
  14.  
  15. Try
  16. lblResult.ForeColor = Drawing.Color.Black ' reset the font color
  17.  
  18. loanAmount = Convert.ToDouble(txtLoanAmount.Text)
  19. interestRate = Convert.ToDouble(txtInterestRate.Text) / 100 ' Convert to decimal
  20. loanTerm = Convert.ToDouble(txtLoanTerm.Text) * 12 ' Convert years to months
  21.  
  22. Catch ex As Exception
  23. lblResult.ForeColor = Drawing.Color.Red
  24. lblResult.Text = "Invalid values were entered"
  25. Exit Sub
  26. End Try
  27.  
  28. If loanAmount <= 0 OrElse loanTerm <= 0 Then
  29.  
  30. lblResult.Text = "Please enter positive values for loan amount and term."
  31. lblResult.ForeColor = Drawing.Color.Red
  32. Exit Sub
  33. End If
  34.  
  35. Dim monthlyInterestRate As Double = interestRate / 12
  36.  
  37. lblResult.Text = "It was clicked"
  38.  
  39. End Sub
  40. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement