2017-11-05 8 views
-5

に適用することはできないと私は演算子*は、オペランドに適用することができないタイプのテキストボックスのオペランドに適用し、 演算子*をint型することはできません 演算子*融資申し込みをしようとオペランドC#

エラー

としてこれを取得していますタイプのテキストボックスをダブル

の私のコードは、この

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 

namespace MyApp3 
{ 
    public partial class LoanApplication : Form 
    { 
     double InterestRate, monthlyInterestRate, loanAmount, monthlyPayment, TotalPayment; 
     int NoOfyears; 

     private void button1_Click(object sender, EventArgs e) 
     { 
      InterestRate = Convert.ToDouble(rate.Text); 
      monthlyInterestRate = InterestRate/1200; 
      NoOfyears = Convert.ToInt32(noOfYrs.Text); 
      loanAmount = Convert.ToDouble(txtLoanAmt.Text); 

      monthlyPayment = loanAmount * monthlyInterestRate/(1 - 1/Math.Pow(1 + monthlyInterestRate,noOfYrs * 12)); // This Line 

      iMonthlyPayment = Convert.ToString(monthlyPayment); 
      iMonthlyPayment = String.Format("{0:C}", monthlyPayment); 
      monthly_payment.Text = (iMonthlyPayment); 

      TotalPayment = monthlyPayment * noOfYrs * 12; // This Line 
      iTotalPayment = String.Format("{0:C}", TotalPayment); 
      total_payment.Text = (iTotalPayment); 

      txtLoanAmt.Text = String.Format("{0:C}", txtLoanAmt.Text); 
     } 

     string iMonthlyPayment, iTotalPayment; 
     public LoanApplication() 
     { 
      InitializeComponent(); 
     } 

     private void groupBox1_Enter(object sender, EventArgs e) 
     { 

     } 

     private void LoanApplication_Load(object sender, EventArgs e) 
     { 
      this.FormBorderStyle = FormBorderStyle.FixedDialog; 
     } 
    } 
} 

のように見える私はここで、正確に何をしないのですか?

+0

エラーメッセージのどの部分が不明瞭に見えますか? – mustaccio

+0

@mustaccioこの行** monthlyPayment = loanAmount * monthlyInterestRate /(1 - 1/Math.Pow(1 + monthlyInterestRate、noOfYrs * 12)); **およびThis Line ** TotalPayment = monthlyPayment * noOfYrs * 12; ** – Qalid

+1

C#では、識別子は大文字と小文字を区別します。 –

答えて

0

問題のある行では、変数noOfYrs(TextBlockの代わりにNoOfyears)が使用されています。これは整数です。

+0

を修正しました。ありがとうございました。 – Qalid

0

あなたはtextbox * intを実行しようとしています。テキストボックスはオブジェクトであり、Doubleでint倍にすることはできません。最初にテキストボックスから値を取得し、それをint intまたはDoubleにキャストする必要があります。例えば。 int.Parse(myTextbox.Text)* myInt

+0

'(int)myTextbox.Text' :)) –

+0

おい、それは間違っている。あなたはint.Parse(myText.Text)またはConvertを意味しました... –

+0

はい、私の悪いです。私はそれを解決したと思った – Matt

関連する問題