-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest030914
143 lines (117 loc) · 4.43 KB
/
Test030914
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test_030914
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Here i made a class that allows me to access my variables from anywhere in the program.
class Variables
{
//Public makes it available, Static means its properties doesnt change and Int or string is the type of variable. (you can also have Bool for Boolean)
public static int MainValue =0;
public static string Colour = "Control";
}
public void Form1_Load(object sender, EventArgs e)
{
//In this Method stub, is the code that is executed when the program is first started
Variables.MainValue = 0;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
public void btnPlus_Click(object sender, EventArgs e)
{
// MainVal++ increases the number by 1
Variables.MainValue++;
//I create a exclusive variable which allows me to convert from number to text (.tostring)
string MainValueText = Variables.MainValue.ToString();
//Sets the Value of the label
LblNum.Text = MainValueText;
}
private void btnMinus_Click(object sender, EventArgs e)
{
// MainVal++ decreases the number by 1
Variables.MainValue--;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnX2_Click(object sender, EventArgs e)
{
// MainVal++ multiplies the number by 2
Variables.MainValue = Variables.MainValue * 2;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnD2_Click(object sender, EventArgs e)
{
// MainVal++ divides the number by 2
Variables.MainValue = Variables.MainValue / 2;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnD10_Click(object sender, EventArgs e)
{
// MainVal++ multiplies the number by 10
Variables.MainValue = Variables.MainValue / 10;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnX10_Click(object sender, EventArgs e)
{
// MainVal++ divides the number by 10
Variables.MainValue = Variables.MainValue * 10;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnNeg_Click(object sender, EventArgs e)
{
Variables.MainValue = (-Variables.MainValue);
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnPos_Click(object sender, EventArgs e)
{
Variables.MainValue = (+Variables.MainValue);
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
}
private void btnSet_Click(object sender, EventArgs e)
{
int SetTo;
SetTo = Convert.ToInt32(txtSet.Text);
Variables.MainValue = SetTo;
string MainValueText = Variables.MainValue.ToString();
LblNum.Text = MainValueText;
txtSet.Text = string.Empty;
}
private void btnBgBlack_Click(object sender, EventArgs e)
{
BackColor = Color.Black;
LblNum.ForeColor = Color.White;
}
private void btnBgWhite_Click(object sender, EventArgs e)
{
BackColor = Color.White;
LblNum.ForeColor = Color.Black;
}
private void btnBgRed_Click(object sender, EventArgs e)
{
BackColor = Color.Red;
LblNum.ForeColor = Color.White;
}
private void button1_Click(object sender, EventArgs e)
{
BackColor = Color.FromName("Control");
LblNum.ForeColor = Color.Black;
}
}
}