Advertisement
fursty

kurec C# v2.0 - ft to inch

Oct 8th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace up3cc
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. double[,] k = new double[4, 4];
  21.  
  22.  
  23. private void Form1_Load(object sender, EventArgs e)
  24. {
  25.  
  26.  
  27. comboBox1.Items.Add("ft");
  28. comboBox1.Items.Add("inch");
  29. comboBox1.Items.Add("miles");
  30. comboBox1.Items.Add("yards");
  31. comboBox1.SelectedIndex = 0;
  32. comboBox2.Items.Add("ft");
  33. comboBox2.Items.Add("inch");
  34. comboBox2.Items.Add("miles");
  35. comboBox2.Items.Add("yards");
  36. comboBox2.SelectedIndex = 0;
  37. k[0, 0] = 1;
  38. k[0, 1] = 2;
  39. k[0, 2] = 3;
  40. k[0, 3] = 4;
  41. k[1, 0] = 5;
  42. k[1, 1] = 6;
  43. k[1, 2] = 7;
  44. k[1, 3] = 8;
  45. k[2, 0] = 9;
  46. k[2, 1] = 10;
  47. k[2, 2] = 11;
  48. k[2, 3] = 12;
  49. k[3, 0] = 13;
  50. k[3, 1] = 14;
  51. k[3, 2] = 15;
  52. k[3, 3] = 16;
  53. }
  54.  
  55. void calc()
  56. { textBox4.Text = (double.Parse(textBox1.Text) * k[comboBox1.SelectedIndex, comboBox2.SelectedIndex]).ToString(); }
  57. private void button1_Click(object sender, EventArgs e)
  58. {
  59. textBox4.Text = (double.Parse(textBox1.Text) * k[comboBox1.SelectedIndex, comboBox2.SelectedIndex]).ToString();
  60.  
  61.  
  62. }
  63.  
  64. private void button2_Click(object sender, EventArgs e)
  65. {
  66. Application.Exit();
  67. }
  68.  
  69. private void button3_Click(object sender, EventArgs e)
  70. {
  71. textBox1.Clear();
  72. textBox4.Clear();
  73. }
  74. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  75. {
  76. if (textBox1.Text != "")
  77. calc();
  78.  
  79.  
  80. }
  81.  
  82.  
  83. private void textBox1_TextChanged(object sender, EventArgs e)
  84. {
  85. if (textBox1.Text != "")
  86. calc();
  87. }
  88.  
  89. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  90. {
  91. if (textBox1.Text != "")
  92. calc();
  93. }
  94.  
  95.  
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement