So I have an invoice total form that should calculate the percentage discount among other things. I'm adding a second form to the code that allows you to change the sales tax I got it to populate the form and actually work with no errors but I can't get it to move the data from the textbox on frmSalesTax to the txtSalesTax.Text in frmInvoiceTotal.
frmInvoiceTotal Code:
public frmInvoiceTotal()
{
InitializeComponent();
}
frmSalesTax percent = new frmSalesTax();
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal productTotal = Convert.ToDecimal(txtProductTotal.Text);
decimal salesTax = (7.75m/100m) * productTotal;
decimal discountPercent = .0m;
if (productTotal < 100)
discountPercent = .0m;
else if (productTotal >= 100 && productTotal < 250)
discountPercent = .1m;
else if (productTotal >= 250)
discountPercent = .25m;
decimal discountAmount = (productTotal + salesTax) * discountPercent;
decimal subtotal = productTotal - discountAmount;
decimal invoiceTotal = (subtotal + salesTax) - discountAmount;
txtSubtotal.Text = subtotal.ToString("c");
txtSalesTax.Text = salesTax.ToString("c");
txtDiscountPercent.Text = discountPercent.ToString("p1");
txtDiscountAmount.Text = discountAmount.ToString("c");
txtTotal.Text = invoiceTotal.ToString("c");
txtProductTotal.Focus();
}
private void btnChange_Click(object sender, EventArgs e)
{
percent.salesTax = txtSalesTax.Text;
switch (percent.ShowDialog())
{
case DialogResult.OK:
txtSalesTax.Text = percent.salesTax;
break;
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
invoiceTotal GUI:
frmSalesTax Code:
public partial class frmSalesTax : Form
{
public string salesTax
{
get;
set;
}
public frmSalesTax()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
this.salesTax = txtPercent.Text;
txtPercent.Text = "";
Hide();
}
I know I'm missing something but I can't figure out what it is.
salesTax GUI:
You've got the right idea making a property on frmSalesTax to communicate...but you're not really using it.
In your frmInvoiceTotal, you need to send the current value to frmSalesTax.salesTax and then handle the results of the percent dialog returning DialogResult.OK:
private void btnChange_Click(object sender, EventArgs e)
{
percent.salesTax = txtSalesTax.Text; //--> send current value to frmSalesTax
switch ( percent.ShowDialog() ) //--> ShowDialog will return the DialogResult of the pressed button
{
case DialogResult.OK:
txtSalesTax.Text = percent.salesTax; //--> update with new value from frmSalesTax
break;
}
}
...and, in your frmSalesTax, you need to put the txtPercent.Text into the salesTax property when the user clicks the OK button:
private void btnOk_Click(object sender, EventArgs e)
{
this.salesTax = txtPercent.Text; //--> frmInvoiceTotal will read this after the OK button is clicked
txtPercent.Text = "";
Hide();
}
Important: you have to make sure the frmSalesTax buttons have their DialogResult set, so that frmInvoiceTotal.btnOk_Click knows that it's okay to get the value:
Edit
The property (in frmSalesTax) needs to not be based on the form's text values...because you're setting that to "" when the form hides. This is what you want for the property:
public string salesTax
{
get;
set;
}
This would go with the other changes I mentioned earlier.
Edit 2
It's easy to get frustrated. There are a lot of moving pieces, and I can understand how the eyes can cross. Here's the crux of the issue - your calculation is trashing things on you;-)
These lines in the btnCalculate_Click:
decimal salesTax = (7.75m/100m) * productTotal;
decimal discountPercent = .0m;
//...
txtSalesTax.Text = salesTax.ToString("c");
txtDiscountPercent.Text = discountPercent.ToString("p1");
...should be the initial values and come in the form's initialization code:
public frmInvoiceTotal()
{
InitializeComponent();
decimal salesTax = (7.75m/100m) * productTotal;
decimal discountPercent = .0m;
txtSalesTax.Text = salesTax.ToString("c"); //--> the initial value
txtDiscountPercent.Text = discountPercent.ToString("p1");
}
...and then, the calculation should not re-populate txtSalesTax.Text or txtDiscountPercent.Text. The txtSalesTax.Text might be update from showing frmSalesTax, and I'm guessing you're gonna make another form to override discount percent at some point.
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal productTotal = Convert.ToDecimal(txtProductTotal.Text);
decimal salesTax = Convert.ToDecimal(salesTax.Text) * productTotal; //--> if it got changed in frmSalesTax
decimal discountPercent = .0m;
if (productTotal < 100)
discountPercent = .0m;
else if (productTotal >= 100 && productTotal < 250)
discountPercent = .1m;
else if (productTotal >= 250)
discountPercent = .25m;
decimal discountAmount = (productTotal + salesTax) * discountPercent;
decimal subtotal = productTotal - discountAmount;
decimal invoiceTotal = (subtotal + salesTax) - discountAmount;
txtSubtotal.Text = subtotal.ToString("c");
//txtSalesTax.Text = salesTax.ToString("c"); //--> don't do this...it steps on what came from frmSalesTax
//txtDiscountPercent.Text = discountPercent.ToString("p1"); //--> when you add another form to override this
txtDiscountAmount.Text = discountAmount.ToString("c");
txtTotal.Text = invoiceTotal.ToString("c");
txtProductTotal.Focus();
}
I bet this get you a lot closer :-)
Related
The following problem though I can not seem to solve by using google.
The program I am writing ask for an amount of shoes that are going to be purchased, then based on amount of shoes a discount is given, 0%, 15%, or 25%.
I have it all written so that the right price appears in a label, the only thing I need to do is make the according radiobutton check itself ( 0%, 15%, or 25%)
Can somebody tell me the syntax?
Code I have written thus far:
private void button1_Click(object sender, EventArgs e)
{
decimal schoenen1= 0;
schoenen1 = Convert.ToDecimal(textBox1.Text);
decimal prijs1 = schoenen1 * 100;
decimal prijs2 = schoenen1 * 85;
decimal prijs3 = schoenen1 * 75;
if (schoenen1 >5)
{
label3.Text = prijs3.ToString();
}
if (schoenen1 == 2)
{
label3.Text = prijs2.ToString();
}
if (schoenen1 >2)
{
label3.Text = prijs2.ToString();
}
if (schoenen1 == 1)
{
label3.Text = prijs1.ToString();
}
Since you want to assign the label only once, use if-else, otherwise e.g. when schoenen1 = 6 then case > 5 and case > 2 will both be executed.
private void button1_Click(object sender, EventArgs e)
{
decimal schoenen1 = Convert.ToDecimal(textBox1.Text);
decimal prijs1 = schoenen1 * 100;
decimal prijs2 = schoenen1 * 85;
decimal prijs3 = schoenen1 * 75;
if (schoenen1 > 5) {
label3.Text = prijs3.ToString();
radioButton1.Checked = true;
} else if (schoenen1 >= 2) {
label3.Text = prijs2.ToString();
radioButton2.Checked = true;
} else if (schoenen1 == 1) {
label3.Text = prijs1.ToString();
radioButton3.Checked = true;
}
}
Also, you can combine schoenen1 == 2 and schoenen1 > 2 into schoenen1 >= 2, since you are assigning the same value in both cases.
Alternatively, you can exit the method with return:
private void button1_Click(object sender, EventArgs e)
{
decimal schoenen1 = Convert.ToDecimal(textBox1.Text);
decimal prijs1 = schoenen1 * 100;
decimal prijs2 = schoenen1 * 85;
decimal prijs3 = schoenen1 * 75;
if (schoenen1 > 5) {
label3.Text = prijs3.ToString();
radioButton1.Checked = true;
return;
}
if (schoenen1 >= 2) {
label3.Text = prijs2.ToString();
radioButton2.Checked = true;
return;
}
if (schoenen1 == 1) {
label3.Text = prijs1.ToString();
radioButton3.Checked = true;
}
}
Yet another way is to use a switch statement:
switch (schoenen1)
{
case > 5:
label3.Text = prijs3.ToString();
radioButton1.Checked = true;
break;
case >= 2:
label3.Text = prijs2.ToString();
radioButton2.Checked = true;
break;
case 1:
label3.Text = prijs1.ToString();
radioButton3.Checked = true;
break;
}
See also: Selection statements - if, else and switch
I have been trying to get my amortization calculator to work however the ending payment balance does not end on 0 and my code does not output the correct values and I am stuck after doing some googling for a couple hours. I believe my issue is underneath the comment "Listbox Loop." Any help would be appreciated.
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
// Allows for the hotkeys to be used even when out of focus from main form
this.KeyPreview = true;
}
private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
{
// Adds hotkeys; Enter = Calculate, Escape = Exit
if (e.KeyChar == (char)Keys.Enter)
{
calculateButton.PerformClick();
}
else if (e.KeyChar == (char)Keys.Escape)
{
exitButton.PerformClick();
}
}
private void rebateCheck_CheckedChanged(object sender, EventArgs e)
{
// Enables & Disables rebate textbox based on rebate checkbox
if (rebateCheck.Checked == true)
{
rebateBox.Enabled = true;
}
else
{
rebateBox.Clear();
rebateBox.Enabled = false;
}
}
/* Selects data inside of the textbox when tabbing or clicking into it */
private void loanAmountBox_Enter(object sender, EventArgs e)
{
loanAmountBox.SelectAll();
}
private void loanAmountBox_Click(object sender, EventArgs e)
{
loanAmountBox.SelectAll();
}
private void annualAPRBox_Enter(object sender, EventArgs e)
{
annualAPRBox.SelectAll();
}
private void annualAPRBox_Click(object sender, EventArgs e)
{
annualAPRBox.SelectAll();
}
private void rebateBox_Enter(object sender, EventArgs e)
{
rebateBox.SelectAll();
}
private void rebateBox_Click(object sender, EventArgs e)
{
rebateBox.SelectAll();
}
/* Clears the list box when text is changed on any of the input boxes */
private void loanAmountBox_TextChanged(object sender, EventArgs e)
{
loanListBox.Items.Clear();
}
private void annualAPRBox_TextChanged(object sender, EventArgs e)
{
loanListBox.Items.Clear();
}
private void rebateBox_TextChanged(object sender, EventArgs e)
{
loanListBox.Items.Clear();
}
/* Only allows digits, periods, and control keys to be entered into textboxes */
private void loanAmountBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
return;
}
}
private void annualAPRBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
return;
}
}
private void rebateBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
return;
}
}
private void exitButton_Click(object sender, EventArgs e)
{
// Asks the user if they are sure they want to exit
DialogResult dialog = MessageBox.Show("Are you sure you want to exit?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); ;
if (dialog == DialogResult.Yes)
this.Close();
}
private void calculateButton_Click(object sender, EventArgs e)
{
// Declaring all variables
int monthsCounter;
double loan;
double rate;
double rebate;
double principal;
double balance;
int months = 0;
double principalPayment = 0;
double pmt = 0;
double interest = 0;
double totalInterest = 0;
double totalPrincipal = 0;
double totalPayment = 0;
double monthlyRate;
try
{
// Parse data from textboxes
double.TryParse(loanAmountBox.Text, out loan);
double.TryParse(annualAPRBox.Text, out rate);
double.TryParse(rebateBox.Text, out rebate);
// Check which loan month radio button is selected
if (loan6Months.Checked)
{
months = 6;
}
else if (loan12Months.Checked)
{
months = 12;
}
else if (loan18Months.Checked)
{
months = 18;
}
else if (loans24Months.Checked)
months = 24;
// Validates if the Loan Amount textbox is blank and if so, throws an error message pop up
if (loan == 0)
{
MessageBox.Show("Please enter a loan value.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
loanAmountBox.Focus();
loanAmountBox.SelectAll();
}
else if (rate == 0)
{
MessageBox.Show("Please enter/select an APR value.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
annualAPRBox.Focus();
annualAPRBox.SelectAll();
}
rate = (rate / 100) / 12;
loan = loan - rebate;
// Listbox loop
for (monthsCounter = 1; monthsCounter <= months; monthsCounter = monthsCounter + 1)
{
// Add to total variables
totalInterest += interest;
totalPrincipal += principalPayment;
totalPayment += pmt;
// Calculate the principal payment
interest = loan * rate;
principalPayment = (loan * rate * Math.Pow(1 + rate, months)) / (Math.Pow(1 + rate, months) - 1);
pmt = principalPayment + interest;
loan = loan - principalPayment;
// Output data to listbox
loanListBox.Items.Add(String.Format("{0,5}{1,12}{2,12}{3,12}{4,12}", monthsCounter, interest.ToString("N2"), principalPayment.ToString("N2"), pmt.ToString("N2"), loan.ToString("N2")));
}
loanListBox.Items.Add("");
loanListBox.Items.Add(String.Format("{0,5}{1,12}{2,12}{3,12}", "Total", totalInterest.ToString("N2"), totalPrincipal.ToString("N2"), totalPayment.ToString("N2")));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
This is what my output looks like when running the program:
However, the output is supposed to be this:
The formula you're using for amortization is correct, it's what you do after this that is giving you the wrong result. principalPayment is the total payment which includes interest. You should probably rename this to totalPayment because the name is misleading. If you know the total payment amount, and you know the interest. How are you going to get the principal amount?
Interest + Principal = Total Payment
Update:
Keep in mind that the loan value used in the amortization formula is not changed--the original loan amount is used for all calculations.
Any time you see "???", it means that you need to fill in the code.
You may consider adding a variable:
double originalLoanAmount = 0;
Then put the loan amount into originalLoanAmount.
double.TryParse(loanAmountBox.Text, out originalLoanAmount);
Set initial values before the "for" loop:
originalLoanAmount = ???
balance = ???
How do you calculate the interest?
interest = ???
Calculate total payment: (original loan amount doesn't change)
pmt = (originalLoanAmount * rate * Math.Pow(1 + rate, months)) / (Math.Pow(1 + rate, months) - 1);
What's the principalPayment?
principalPayment = ???
What's the new balance?
balance = ???
Here is what my code looks like in the first page:
protected void btnCalculate_Click(object sender, EventArgs e)
{
if (IsValid)
{
decimal salesPrice = Convert.ToDecimal(txtSalesPrice.Text);
decimal discountPercent = Convert.ToDecimal(txtDiscountPercent.Text) / 100;
decimal discountAmount = salesPrice * discountPercent;
decimal totalPrice = salesPrice - discountAmount;
lblDiscountAmount.Text = discountAmount.ToString("c");
lblTotalPrice.Text = totalPrice.ToString("c");
Session.Add("salesPrice", salesPrice);
Session.Add("discountAmount", discountAmount);
Session.Add("totalPrice", totalPrice);
}
}
protected void btnConfirm_Click(object sender, EventArgs e)
{
if (Session["salesPrice"] == null)
{
lblMessage.Text = "Click the Calculate button before you confirm.";
}
else
{
Response.Redirect("Confirm.aspx");
}
}
And now I try to capture those variables:
protected void Page_Load(object sender, EventArgs e)
{
TextBox salesPrice = (TextBox)Session["salesPrice"];
TextBox discountAmount = (TextBox)Session["discountAmount"];
TextBox totalPrice = (TextBox)Session["totalPrice"];
Change your code from this:
TextBox salesPrice = (TextBox)Session["salesPrice"];
TextBox discountAmount = (TextBox)Session["discountAmount"];
TextBox totalPrice = (TextBox)Session["totalPrice"];
to:
salesPrice.Text = Session["salesPrice"].ToString();
discountAmount.Text = Session["discountAmount"].ToString();
totalPrice.Text = Session["totalPrice"].ToString();
Here, salesPrice, discountAmount, totalPrice are Textboxes. As a good practice, you can check whether the Session["fieldname"] is not null etc..
I am working on a Windows Form. Every time I press Calculate or clear, nothing happens. The form loads but buttons won't work. Textboxes remain clear, with no values. Visual Studio doesn't recognize the code as a mistake. Any help?
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
int numberOfInvoices = 0;
decimal totalOfInvoices = 0m;
decimal invoiceAverage = 0m;
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal txtSubtotal = Convert.ToDecimal(txtEnterSubtotal.Text);
decimal discountPercent = .25m;
if (txtSubtotal >= 500)
{
discountPercent = .2m;
}
else if (txtSubtotal >= 250 && txtSubtotal < 500)
{
discountPercent = .15m;
}
else if (txtSubtotal >= 100 && txtSubtotal < 250)
{
discountPercent = .1m;
}
else
{
discountPercent = .0m;
}
decimal discountAmount = Math.Round(txtSubtotal * discountPercent, 2);
decimal invoiceTotal = txtSubtotal - discountAmount;
this.txtSubtotal.Text = txtSubtotal.ToString("c");
txtDiscountPercent.Text = discountPercent.ToString("p1");
txtDiscountAmount.Text = discountAmount.ToString("c");
txtTotal.Text = invoiceTotal.ToString("c");
numberOfInvoices++;
totalOfInvoices += invoiceTotal;
invoiceAverage = totalOfInvoices / numberOfInvoices;
txtNumberOfInvoices.Text = numberOfInvoices.ToString();
txtTotalOfInvoices.Text = totalOfInvoices.ToString("c");
txtInvoiceAverage.Text = invoiceAverage.ToString("c");
txtEnterSubtotal.Text = "";
txtEnterSubtotal.Focus();
}
private void btnClearTotals_Click(object sender, System.EventArgs e)
{
numberOfInvoices = 0;
totalOfInvoices = 0m;
invoiceAverage = 0m;
txtNumberOfInvoices.Text = "";
txtTotalOfInvoices.Text = "";
txtInvoiceAverage.Text = "";
txtEnterSubtotal.Focus();
}
}
}
I really appreciate your help, please let me know how I could improve.
Both your click handlers seem to work fine. I am guessing you don't have them connected to the button objects for some reason. Maybe you created them, saved the Form1.cs file, and then opened the Form in designer and hit undo or something like that.
You should be able to make them work again by opening the form in designer, double-clicking the button and move the code to the new method created by the designer.
Once connected, the Form1.Designer.cs should contain the following line:
this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
and similar for the clear button.
I have a form application in C#. I need to take radiobutton values in textbox.i know the methods are private, i change public but it didnt work. i need to take value1,value2,value3 and value4 with button press. Can anybody tell me a way for getting values in textboxs....
private void groupBox1_Enter(object sender, EventArgs e)
{
double value1;
if (radioButton1.Checked)
value1 = 0.9;
else if (radioButton2.Checked)
value1 = 0.8;
else if (radioButton3.Checked)
value1 = 0.7;
else if (radioButton4.Checked)
value1 = 0.3;
else if (radioButton5.Checked)
value1 = 0.5;
else
MessageBox.Show("Oda Tipi girilmedi.");
}
private void groupBox2_Enter(object sender, EventArgs e)
{
double value2;
if (radioButton6.Checked)
value2 = 1;
else if (radioButton7.Checked)
value2 = 0.8;
else if (radioButton8.Checked)
value2 = 0.6;
else
MessageBox.Show("İzolasyon Tipi girilmedi.");
}
private void groupBox3_Enter(object sender, EventArgs e)
{
double value3;
if (radioButton9.Checked)
value3 = 0.9;
else if (radioButton10.Checked)
value3 = 1;
else
MessageBox.Show("Cam Tipi girilmedi.");
}
private void groupBox4_Enter(object sender, EventArgs e)
{
double value4;
if (radioButton11.Checked)
value4 = 1;
else if (radioButton12.Checked)
value4 = 0.9;
else
MessageBox.Show("Formül katsayısı girilmedi.");
}
private void button1_Click(object sender, EventArgs e)
{
textBox5.Text=Convert.ToString(value1*value2*value3*value4*(Convert.ToDouble(textBox2.Text))*(Convert.ToDouble(textBox3.Text))*(Convert.ToDouble(textBox4.Text)));
}
You can either move the variables (value1 etc.) to the class scope or put everything in the button1_Click event handler like #SteveDanner has suggested or you may write a more generic solution. It can be very easily extendend if you create more options (RadioButtons).
// Store values for each RadioButton in a dictionary.
private Dictionary<RadioButton, double> values =
new Dictionary<RadioButton, double>();
private Dictionary<GroupBox, string> messages =
new Dictionary<GroupBox, string>();
public Form1()
{
InitializeComponent();
// Associate values with radio buttons.
values[radioButton1] = 0.9;
// repeat the same for others...
// Associate values messages with group boxes.
messages[groupBox1] = "Oda Tipi girilmedi.";
// repeat the same for others...
}
#region GroupBox.Enter event handlers.
private void groupBox1_Enter(object sender, EventArgs e)
{
RadioButton radioButton = GetSelectedRadioButton(sender as GroupBox);
if (radioButton == null)
{
MessageBox.Show(messages[sender as GroupBox]);
}
}
// Here you can either repeat the same for other group boxes
// or simply assign this event hander to all of them.
// It will get the right message for each group.
#endregion
// Gets the selected radio button from the specified group.
private void RadioButton GetSelectedRadioButton(GroupBox groupBox)
{
RadioButton radioButton =
groupBox
.Controls
.OfType<RadioButton>()
.Where(rb => rb.Checked)
.FirstOrDefault();
return radioButton;
}
// Gets selected value from the specified group.
private double GetSelectedValue(GroupBox groupBox)
{
RadioButton radioButton = GetSelectedRadioButton(groupBox);
if (radioButton == null)
{
// Nothing selected yet.
return double.NaN;
}
else
{
// Get the value from the dictinary.
return values[radioButton];
}
}
private void button1_Click(object sender, EventArgs e)
{
// Get the selected values.
double value1 = GetSelectedValue(groupBox1);
double value2 = GetSelectedValue(groupBox2);
double value3 = GetSelectedValue(groupBox3);
double value4 = GetSelectedValue(groupBox4);
// Check other values in the same way.
if (double.IsNaN(value1))
{
MessageBox.Show(message[groupBox1]);
}
textBox5.Text = Convert.ToString(
value1
* value2
* value3
* value4
* (Convert.ToDouble(textBox2.Text))
* (Convert.ToDouble(textBox3.Text))
* (Convert.ToDouble(textBox4.Text)));
}
The problem is that your values being created from the RadioButtons are local variables to the method handlers. You need to remove your groupBox_Enter handlers and just handle the button1_Click event like so:
private void button1_Click(object sender, EventArgs e)
{
double value1;
if (radioButton1.Checked)
value1 = 0.9;
else if (radioButton2.Checked)
value1 = 0.8;
else if (radioButton3.Checked)
value1 = 0.7;
else if (radioButton4.Checked)
value1 = 0.3;
else if (radioButton5.Checked)
value1 = 0.5;
else
{
MessageBox.Show("Oda Tipi girilmedi.");
return; //not sure if this is what you want here?
}
double value2;
if (radioButton6.Checked)
value2 = 1;
else if (radioButton7.Checked)
value2 = 0.8;
else if (radioButton8.Checked)
value2 = 0.6;
else
{
MessageBox.Show("Izolasyon Tipi girilmedi.");
return; //not sure if this is what you want here?
}
double value3;
if (radioButton9.Checked)
value3 = 0.9;
else if (radioButton10.Checked)
value3 = 1;
else
{
MessageBox.Show("Cam Tipi girilmedi.");
return; //not sure if this is what you want here?
}
double value4;
if (radioButton11.Checked)
value4 = 1;
else if (radioButton12.Checked)
value4 = 0.9;
else
{
MessageBox.Show("Formül katsayisi girilmedi.");
return; //not sure if this is what you want here?
}
textBox5.Text=Convert.ToString(value1*value2*value3*value4*(Convert.ToDouble(textBox2.Text))*(Convert.ToDouble(textBox3.Text))*(Convert.ToDouble(textBox4.Text)));
}