Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 upr3c
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (textBox1.Text != "")
- calc();
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- if (textBox1.Text != "")
- calc();
- }
- void calc()
- {
- double p, r;
- if (comboBox1.Text == "F")
- {
- p = double.Parse(textBox1.Text);
- r=(p-32)*5/9;
- textBox2.Text = r.ToString();
- }
- if (comboBox1.Text == "C")
- {
- p = double.Parse(textBox1.Text);
- r = p*9/5+32;
- textBox2.Text = r.ToString();
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- comboBox1.Items.Add("F");
- comboBox1.Items.Add("C");
- comboBox1.SelectedIndex = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment