I am trying to figure out how to finish this program and get the calculations to display in the textboxes. This is what I have so far and basically the code will take the purchase price and the redemption rate and calculate the discount and interest rate. Not sure what I am doing wrong though.
Option Strict On
Public Class _Default
Inherits System.Web.UI.Page
Dim Purchase As Double
Dim Redemption As Double
Dim DiscountRate As Double
Dim InterestRate As Double
Protected Sub btnCalculate_Click(sender As Object, e As EventArgs) _
Handles btnCalculate.Click
Double.TryParse(txtPurchase.Text, Purchase)
Double.TryParse(txtRedemption.Text, Redemption)
Double.TryParse(txtDiscount.Text, DiscountRate)
Double.TryParse(txtInterest.Text, InterestRate)
If (CDbl(txtPurchase.Text) <= 0) Then
MsgBox("Please enter an amount greater than 0")
End If
If (CDbl(txtRedemption.Text) <= 0) Then
MsgBox("Please enter an amount greater than 0")
End If
DiscountRate = Purchase - Redemption / Purchase
InterestRate = Purchase - Redemption / Redemption
End Sub
End Class
They variables aren’t automatically bound to the control when you parse them. Looks like you just need to add this after your calculations: