0% found this document useful (0 votes)
81 views4 pages

Assignment 3: Name: Index: Course Code: Bitm301 Course Title: Programming Session: Morning

The document describes a calculator application created by Makafui Divine Gati-Kwashie. The application contains a user interface with a textbox and 17 buttons for numbers 0-9, operations like addition and subtraction, and a clear button. Variables are declared to store input numbers and the selected operation. Buttons are programmed so that clicking adds the corresponding number to the textbox. Operations buttons store the first input number, clear the textbox, and select the operation. The equal button calculates the result based on the stored operation and displays the output.

Uploaded by

Son Samuel Kesse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views4 pages

Assignment 3: Name: Index: Course Code: Bitm301 Course Title: Programming Session: Morning

The document describes a calculator application created by Makafui Divine Gati-Kwashie. The application contains a user interface with a textbox and 17 buttons for numbers 0-9, operations like addition and subtraction, and a clear button. Variables are declared to store input numbers and the selected operation. Buttons are programmed so that clicking adds the corresponding number to the textbox. Operations buttons store the first input number, clear the textbox, and select the operation. The equal button calculates the result based on the stored operation and displays the output.

Uploaded by

Son Samuel Kesse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

NAME: MAKAFUI DIVINE GATI-KWASHIE

INDEX: 10098259
COURSE CODE: BITM301
COURSE TITLE: PROGRAMMING
SESSION: MORNING

ASSIGNMENT 3
The image below is the user interface of my calculator application which I named
Makafui Divine Gati-Kwashie. I created a textbox and 17 buttons which include
numbers from 0-9, operations such as addition (+), subtraction (-), multiplication (*)
and division (/) also a dot(.) to interpret decimal values, an equal to sign (=) and a
clear(C) button for clearing text in the textbox.

INPUT

After the design process, I proceeded to the form.vb where I was able to write the
codes for the various buttons and textbox.

Before my program will be able to run, I declared some variables with my initials
which is shown below:
Public Class Form1

Dim MDGKfirstnum As Decimal


Dim MDGKsecondnum As Decimal
Dim MDGKoperations As Integer
Dim MDGKoperator_selector As Boolean = False

Private Sub Form1_Load(sender As Object, e As EventArgs) HandlesMyBase.Load


End Sub
I proceeded to write specific action for all buttons. In the code, I declared that when
a button is clicked, the number on the button is displayed in the textbox. This is
illustrated below:

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles


Button5.Click
If TextBox1.Text <> "0" Then
TextBox1.Text += "1"
Else
TextBox1.Text = "1"
End If
End Sub
The above process is repeated for all numbers between 1-9

PROCESSES AND OUTPUT

When a user inputs two numbers i.e., MDGKfirstnum and MDGKsecondnum, and uses an
operation (+, -, *, /), an answer should be provided in the textbox. Example
MDGKfirstnum + MDGKsecondnum = output

This is further explained below:

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click


MDGKfirstnum = TextBox1.Text
TextBox1.Text = "0"
MDGKoperator_selector = True
MDGKoperations = 1 ' = +
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


MDGKfirstnum = TextBox1.Text
TextBox1.Text = "0"
MDGKoperator_selector = True
MDGKoperations = 2 ' = -
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


MDGKfirstnum = TextBox1.Text
TextBox1.Text = "0"
MDGKoperator_selector = True
MDGKoperations = 3 ' = *
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


MDGKfirstnum = TextBox1.Text
TextBox1.Text = "0"
MDGKoperator_selector = True
MDGKoperations = 4 ' /
End Sub
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles
Button16.Click
If MDGKoperator_selector = True Then
MDGKsecondnum = TextBox1.Text
If MDGKoperations = 1 Then
TextBox1.Text = MDGKfirstnum + MDGKsecondnum
ElseIf MDGKoperations = 2 Then
TextBox1.Text = MDGKfirstnum - MDGKsecondnum
ElseIf MDGKoperations = 3 Then
TextBox1.Text = MDGKfirstnum * MDGKsecondnum
Else
If MDGKsecondnum = 0 Then
TextBox1.Text = "ERROR !"
Else
TextBox1.Text = MDGKfirstnum / MDGKsecondnum
End If
End If
MDGKoperator_selector = False
End If
End Sub
End Class

You might also like