-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
149 lines (114 loc) · 5.08 KB
/
Form1.vb
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
144
145
146
147
148
149
Public Class Form1
'Create double variables that are private
Private dblIntegerInput, dblTotal As Double
'Converts the imput string into an interger, and clears the input
Private Sub Stringtoint()
'Converts the input into an integer
dblIntegerInput = Convert.ToDouble(txtIntegerInput.Text)
'If the radiobuttons aren't checked
If radKeepTotal.Checked = False And radKeepInput.Checked = False Then
'Clear the textbox
txtIntegerInput.Text = ""
End If
End Sub
'Keeps the total by converting the total to a string
Private Sub KeepTheTotal()
'If the total radio button is checked
If radKeepTotal.Checked = True Then
'Convert the double total to a string and put it in the textbox
txtIntegerInput.Text = Convert.ToString(dblTotal)
End If
End Sub
'When the double button is clicked, the number is checked then doubled.
Private Sub btnDouble_Click(sender As Object, e As EventArgs) Handles btnDouble.Click
'If the box has nothing in it, then display a message
If txtIntegerInput.Text = "" Then
'Display a message
MsgBox("Please provide a number in the textbox", vbExclamation)
Else
'Goes to the subfuntion to convert the input into an integer
Stringtoint()
'Times the input by 2
dblTotal = dblIntegerInput * 2
'Displays it's result
MsgBox("The double of " & dblIntegerInput & " is " & dblTotal)
'Checks if the box is check to keep the total in the inputbox
KeepTheTotal()
End If
End Sub
'When the half button is clicked, the input number is halved.
Private Sub btnHalf_Click(sender As Object, e As EventArgs) Handles btnHalf.Click
'If the input box has nothing in it, then display a message.
If txtIntegerInput.Text = "" Then
MsgBox("Please provide a number in the textbox", vbExclamation)
Else
'Goes to the subfuntion to convert the input into an integer
Stringtoint()
'Half the integer input
dblTotal = dblIntegerInput / 2
'Displays it's results
MsgBox("Half of " & dblIntegerInput & " is " & dblTotal)
'Checks if the box is check to keep the total in the inputbox
KeepTheTotal()
End If
End Sub
' __ __
' | | | |
'_| |_ _| |_
'\ / \ /
' \ / \ /
' \/ EXTRA FEATURES BELOW \/
'When the exit button is pressed, the application closes.
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'Closes the main window.
Me.Close()
End Sub
'When the random number button is clicked, the application puts a random number in the input box.
Private Sub btnRandomNum_Click(sender As Object, e As EventArgs) Handles btnRandomNum.Click
'Declares the RandomNumber as an Integer
Dim RandomNumber As Integer
'Chooses a random number between 0 - 1000
RandomNumber = Math.Ceiling(Rnd() * 1000)
'Assigns the textbox as a random number
txtIntegerInput.Text = RandomNumber
End Sub
'If the Triple button is clicked, the input is multiplied by 4
Private Sub btnTriple_Click(sender As Object, e As EventArgs) Handles btnTriple.Click
'If the inputbox has nothing in it.
If txtIntegerInput.Text = "" Then
'Display a message
MsgBox("Please provide a number in the textbox", vbExclamation)
Else
'Goes to the subfuntion to convert the input into an integer
Stringtoint()
'Times the input by 3
dblTotal = dblIntegerInput * 3
'Displays it's result
MsgBox("The triple of " & dblIntegerInput & " is " & dblTotal)
'Checks if the box is check to keep the total in the inputbox
KeepTheTotal()
End If
End Sub
'If the Quarter button is clicked, the input is divided by 4
Private Sub btnQuarter_Click(sender As Object, e As EventArgs) Handles btnQuarter.Click
If txtIntegerInput.Text = "" Then
'Display a message
MsgBox("Please provide a number in the textbox", vbExclamation)
Else
'Goes to the subfuntion to convert the input into an integer
Stringtoint()
'Divides the input by 4
dblTotal = dblIntegerInput / 4
'Displays it's result
MsgBox("The quarter of " & dblIntegerInput & " is " & dblTotal)
'Checks if the box is check to keep the total in the inputbox
KeepTheTotal()
End If
End Sub
'When the Unselect button is clicked, it clears the radio buttons
Private Sub btnUnselect_Click(sender As Object, e As EventArgs) Handles btnUnselect.Click
'Uncircles the radio buttons
radKeepInput.Checked = False
radKeepTotal.Checked = False
End Sub
End Class