0
Public Class Form1
Private Sub btn_calculate_Click(sender As Object, e As EventArgs) Handles btn_calculate.Click
Dim MonthPayment As Double
Dim LoanAmount As Double = txtbox_loan.Text
Dim IntRate As Double = txtbox_IntRate.Text
Dim Years As Double = txtbox_years.Text
Dim tempI, temp1, temp2 As Double 'temporary variables'
tempI = IntRate/1200
temp1 = (1 + tempI)^((-12) * Years)
temp2 = (tempI/(1 - temp1))
MonthPayment = temp2 * LoanAmount
txtbox_MonthPayment.Text = "$" & Math.Round(MonthPayment, 2)
End Sub
End Class
這是迄今爲止我所擁有的。我不斷收到錯誤A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
,它突出顯示LoanAmount As Double = txtbox_loan.Text,我想我需要改變它是一個字符串,但不知道如何。有什麼建議麼?Visual Basic 2012「在Microsoft.VisualBasic.dll中發生類型'System.InvalidCastException'的第一次機會異常」