0% found this document useful (0 votes)
19 views20 pages

GAD Atharva Microproject

The document outlines a micro project on creating a GUI calculator application using VB.NET, submitted by Pande Atharva Amol under the guidance of Prof. Sawase Mam. It includes sections on the project's aim, requirements, introduction, code examples, advantages, and disadvantages of the application. The project serves as a learning tool for programming concepts, user interface design, and problem-solving skills.

Uploaded by

vg7028975013
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)
19 views20 pages

GAD Atharva Microproject

The document outlines a micro project on creating a GUI calculator application using VB.NET, submitted by Pande Atharva Amol under the guidance of Prof. Sawase Mam. It includes sections on the project's aim, requirements, introduction, code examples, advantages, and disadvantages of the application. The project serves as a learning tool for programming concepts, user interface design, and problem-solving skills.

Uploaded by

vg7028975013
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/ 20

import javax.swing.

*;
import java.awt.*;
import java.awt.Image;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.*;
import javafx.print.Printer;
import java.io.*;
import java.io.IOException;
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
MITTHULALJI SARADA POLYTECHNIC, BEED

Micro Project On :-
1
“ GUI Application of Calculator ”
Under The Guidance Of :-
Prof. Sawase Mam.
For The Subject :-
GUI Application Development Using VB.Net(GAD)(22034)
Department Of
Information Technology
In Academic Year
2023-24
Submitted By:- Pande Atharva Amol (2214920144)

CERTIFICATE

This is to certify that Pande Atharva Amol from Mitthulalji Sarada Polytechnic Beed Institute Having
Enrollment no. 2214920144 has completed Micro Project of second year GUI Application Development
Using VB.Net subject having Title GUI Application of Calculator during academic year 2023-2024 The
project completed by Student under the guidance of the faculty Prof. Sawase A.A.

Name and signature of guide ……………………................................

2
Acknowledgement
A project work of a great significance is not possible without the help of several people, directly or indirectly.
First and foremost we have immense happiness in expressing our sincere thanks to our guide, Prof.Sawase Mam
for her valuable suggestion, co-operating and continuous guidance.

We feel a deep sense of gratitude to Mr. Shaikh S.I., Head of computer science and Information Technology
department for his continuous encouragement and for developing a keen interest in the field of Information
Technology. It's our pleasure to thank Mr.Khadke R.N principal of Mitthulalji Sarada Polytechnic, and Aditya
Polytechnic. Beed, who is always a constant source of inspiration.

We are very much thankful to all our faculty members whose presence always inspires us to do better. Our
happiness culminates, when we recall the co-operation extended our friends during the completion of this
project.

Project Team:- Pande Atharva Amol

3
Index

Sr No. Content Page No.


1. Title 1

2. Certificate 2

3. Acknowledgement 3

4. Aim of the Project 5

5. Requirement 6

6. Introduction 7

7. Code 10

8. Output 14

9. Advantages of Calculator application 15

10. Disadvantages of Calculator application 17

11. Conclusion 18

4
Aim of the Project
The aim of creating a calculator project in VB.NET can serve several purposes:

1. **Learning Basic Programming Concepts**: Building a calculator helps beginners grasp fundamental
programming concepts such as variables, data types, operators, conditional statements, loops, and event
handling.

2. **Understanding User Interface Design**: Designing the calculator's user interface provides insight into
creating interactive applications using Visual Studio's drag-and-drop interface and understanding controls like
buttons, text boxes, and labels.

3. **Practicing Problem-Solving Skills**: Implementing arithmetic operations, error handling, and user input
validation within the calculator project helps sharpen problem-solving skills and logical thinking.

4. **Applying Object-Oriented Principles**: While a simple calculator may not require advanced object-
oriented programming, it provides a foundation for understanding concepts like classes, objects, encapsulation,
and inheritance, which become crucial in larger software projects.

5. **Gaining Experience with VB.NET Syntax**: Writing code for the calculator project helps learners become
familiar with VB.NET syntax, language features, and coding conventions.

6. **Preparing for More Complex Projects**: Although a calculator is a relatively simple application, the skills
acquired during its development can be transferred to more complex projects, providing a solid foundation for
future software development endeavors.

Overall, the aim of the calculator project in VB.NET is to provide a hands-on learning experience that equips
individuals with essential programming skills and prepares them for tackling more significant software
development challenges.

5
Requirements:

Sr Name of resource
Specifications Quantity
No. material
1 Computer System 8 GB RAM, Windows 10 OS 1

2 Internet Youtube/ Google


( GAD )GUI Apllication Development
3 Textbook/manual 1
Using VB.Net (22034)
4 Software Visual Studio Code 2022

6
Introduction

A calculator is a device that


performs arithmetic operations on
numbers. The
simplest calculators can do only
addition, subtraction, multiplication,
and division.
More sophisticated calculators can
handle exponent operations, roots,
logarithm s,
trigonometric functions, and
hyperbolic functions
A calculator is a device that
performs arithmetic operations on
numbers. The
7
simplest calculators can do only
addition, subtraction, multiplication,
and division.
More sophisticated calculators can
handle exponent operations, roots,
logarithm s,
trigonometric functions, and
hyperbolic functions
Creating a basic calculator in VB.NET can be a great way to start learning programming concepts. Let me give
you a simple introduction to building one:

### Step 1: Setting Up Your Project


1. Open Visual Studio.
2. Create a new VB.NET Windows Forms Application project.

### Step 2: Designing the User Interface


1. Drag and drop buttons for numbers (0-9), arithmetic operators (+, -, *, /), and other functionalities like clear,
equal, etc., onto the form.
2. Add a TextBox control to display the input and output.

### Step 3: Writing the Code


Here's a basic structure of what your code might look like:
Public Class CalculatorForm

8
Dim num1 As Double
Dim num2 As Double
Dim operand As String

Private Sub NumberButton_Click(sender As Object, e As EventArgs) Handles btn0.Click, btn1.Click,


btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click
Dim button As Button = CType(sender, Button)
TextBox1.Text &= button.Text
End Sub

Private Sub OperatorButton_Click(sender As Object, e As EventArgs) Handles btnPlus.Click,


btnMinus.Click, btnMultiply.Click, btnDivide.Click
Dim button As Button = CType(sender, Button)
operand = button.Text
num1 = Double.Parse(TextBox1.Text)
TextBox1.Clear()
End Sub

Private Sub EqualsButton_Click(sender As Object, e As EventArgs) Handles btnEquals.Click


num2 = Double.Parse(TextBox1.Text)
Dim result As Double

Select Case operand


Case "+"
result = num1 + num2
Case "-"
result = num1 - num2
Case "*"
result = num1 * num2
Case "/"
If num2 = 0 Then
9
MessageBox.Show("Cannot divide by zero.")
TextBox1.Clear()
Exit Sub
Else
result = num1 / num2
End If
End Select

TextBox1.Text = result.ToString()
End Sub

Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles btnClear.Click


TextBox1.Clear()
End Sub
End Class
```

### Step 4: Testing Your Calculator


1. Build and run your project.
2. Test all functionalities, including basic arithmetic operations, clearing the input, and handling edge cases like
division by zero.

That's a very basic calculator. You can expand it by adding more features like parentheses, exponentiation,
memory functionality, etc. as you become more comfortable with VB.NET programming.

10
Code:-
Public Class calculator

' two numbers to do the calc


Dim num1, num2 As Double
' check if an operator is clicked for the first time
Dim oprClickCount As Integer = 0
' check if an operator is clicked befor
Dim isOprClick As Boolean = False
' check if equal is clicked befor
Dim isEqualClick As Boolean = False
' get the operator
Dim opr As String

Private Sub calculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load

11
' add click event to all button in the form
For Each c As Control In Controls

' if the control is button


If c.GetType() = GetType(Button) Then
If Not c.Text.Equals("Reset") Then
' add action to the button
AddHandler c.Click, AddressOf btn_Click
End If

End If

Next

End Sub

' create a button click event


Private Sub btn_Click(sender As Object, e As EventArgs)

Dim button As Button = sender

If Not isOperator(button) Then


' if number
If isOprClick Then
' if an opr is clicked
' get and convert to double textbox text
num1 = Double.Parse(TextBox1.Text)
' clear textbox text
TextBox1.Text = ""
End If

If Not TextBox1.Text.Contains(".") Then


' if "." not already in the textbox
If TextBox1.Text.Equals("0") AndAlso Not button.Text.Equals(".") Then
TextBox1.Text = button.Text
isOprClick = False
Else
TextBox1.Text += button.Text
isOprClick = False
End If

ElseIf Not button.Text.Equals(".") Then


12
' if the button is not a "."
TextBox1.Text += button.Text
isOprClick = False
End If

Else
' if operator
If oprClickCount = 0 Then
' if we click on an operator for the first time
oprClickCount += 1
num1 = Double.Parse(TextBox1.Text)
opr = button.Text
isOprClick = True

Else
If Not button.Text.Equals("=") Then
' if the button is not "="
If Not isEqualClick Then
' if "=" is not clicked befor
num2 = Double.Parse(TextBox1.Text)
TextBox1.Text = Convert.ToString(calc(opr, num1, num2))
num2 = Double.Parse(TextBox1.Text)
opr = button.Text
isOprClick = True
isEqualClick = False

Else

isEqualClick = False
opr = button.Text

End If

Else

num2 = Double.Parse(TextBox1.Text)
TextBox1.Text = Convert.ToString(calc(opr, num1, num2))
num1 = Double.Parse(TextBox1.Text)
isOprClick = True
isEqualClick = True

End If
13
End If

End If

End Sub

' create a function to check if the button is a number or an operator


Function isOperator(ByVal btn As Button) As Boolean

Dim btnText As String


btnText = btn.Text

If (btnText.Equals("+") Or btnText.Equals("-") Or btnText.Equals("/") Or


btnText.Equals("X") Or btnText.Equals("=")) Then
Return True
Else
Return False
End If

End Function

' create a function to do the calc


Function calc(ByVal op As String, ByVal n1 As Double, ByVal n2 As Double) As Double

Dim result As Double


result = 0

Select Case op

Case "+"
result = n1 + n2
Case "-"
result = n1 - n2
Case "X"
result = n1 * n2
Case "/"
14
If n2 <> 0 Then
result = n1 / n2
End If

End Select

Return result

End Function

Private Sub ButtonReset_Click(sender As Object, e As EventArgs) Handles ButtonReset.Click

num1 = 0
num2 = 0
opr = ""
oprClickCount = 0
isOprClick = False
isEqualClick = False
TextBox1.Text = "0"

End Sub
End Class

Output:-

15
16
Advantages of Calculator Application

Developing a calculator application using VB.NET offers several advantages:

1. **Ease of Development**: VB.NET provides a user-friendly and intuitive development environment,


making it easier for developers to create applications quickly.

2. **Rich User Interface**: VB.NET allows developers to design visually appealing user interfaces using
drag-and-drop controls, making it easy to create a user-friendly calculator interface.

3. **Integration with .NET Framework**: VB.NET is part of the .NET Framework, which provides a
rich set of libraries and tools for building robust applications. Developers can leverage the functionalities of
the .NET Framework to enhance the capabilities of their calculator application.

4. **Object-Oriented Programming**: VB.NET supports object-oriented programming (OOP) principles,


allowing developers to organize their code into reusable and maintainable components. This facilitates code
readability, scalability, and easier maintenance of the calculator application.

5. **Access to .NET Framework Libraries** : VB.NET applications have access to a wide range of
libraries available in the .NET Framework, including math functions, which can be utilized to implement
advanced calculator functionalities.

6. **Platform Independence**: Applications developed in VB.NET can run on various platforms,


including Windows, macOS, and Linux, through the use of frameworks like .NET Core or Xamarin.

7. **Community Support**: VB.NET has a large community of developers who contribute to forums,
tutorials, and other resources. Developers can leverage this community support to troubleshoot issues, learn new
techniques, and enhance their calculator application.

8. **Integration with Other Technologies**: VB.NET can easily integrate with other technologies and
services, such as databases, web services, and third-party APIs. This enables developers to extend the
functionality of their calculator application by incorporating additional features.

17
9. **Scalability**: VB.NET applications can scale seamlessly to accommodate growing user
demands and evolving business requirements. Developers can enhance the calculator application with new
features and functionalities as needed.

10. **Security**: VB.NET provides built-in security features, such as code access security and role-
based security, to help developers create secure calculator applications that protect user data and prevent
unauthorized access.

Overall, developing a calculator application in VB.NET offers a combination of ease of development, rich user
interface capabilities, access to a robust framework, and community support, making it a preferred choice for
many developers.

18
Disadvantages of Calculator Application
While there are numerous advantages to creating a calculator GUI application in VB.NET, there are also some
potential disadvantages to consider:

1. **Limited Complexity**: Calculator applications typically have straightforward functionality. For


developers seeking to create more complex or feature-rich applications, such as those with advanced graphing
capabilities or scientific functions, a calculator GUI may be too simplistic.

2. **Overhead**: Using a GUI framework, such as WinForms or WPF in VB.NET, introduces some
overhead in terms of memory usage and performance compared to a purely console-based application. For
simple calculator applications, this overhead may be negligible, but for extremely lightweight applications, it
could be a consideration.

3. **Learning Curve**: While VB.NET offers a relatively gentle learning curve compared to some
other programming languages, mastering GUI development can still require time and effort. Developers who
are new to VB.NET or GUI programming may find themselves spending additional time learning the necessary
concepts and techniques.

4. **Cross-Platform Limitations**: VB.NET primarily targets the Windows platform. While it


is possible to create cross-platform applications using technologies like .NET Core or Xamarin, there may be
limitations or additional complexities involved in deploying a VB.NET calculator application to non-Windows
platforms.

5. **Dependency on Frameworks**: Calculator GUI applications developed in VB.NET rely on


the .NET Framework or .NET Core runtime to execute. This dependency means that users must have the
appropriate version of the .NET runtime installed on their system to run the application, which could be a
barrier for some users.

6. **Maintainability**: GUI applications, including calculator GUIs, tend to have more complex
code structures compared to console-based applications. This complexity can make the codebase harder to
maintain, especially as the application grows in size or complexity.

19
7. **Resource Consumption**: GUI applications typically consume more system resources (CPU,
memory) compared to console-based applications. While this might not be a significant concern for a simple
calculator application, it could be a consideration for developers targeting resource-constrained environments.

8. **Compatibility Issues**: As technology evolves, there may be compatibility issues with


older VB.NET code or dependencies. Developers may need to update their code or dependencies to ensure
compatibility with newer versions of the .NET Framework or operating systems.

9. **Accessibility**: GUI applications may present accessibility challenges for users with disabilities
compared to console-based applications. Ensuring that the calculator GUI is accessible to all users may require
additional design considerations and testing.

10. **Deployment Complexity**: Deploying a VB.NET calculator GUI application may involve
additional steps compared to a console-based application, such as packaging and distributing dependencies or
ensuring that the application installs correctly on end-user systems.

While these disadvantages should be considered, they may not be significant barriers for developers creating
simple calculator GUI applications in VB.NET, especially if the primary goal is to provide basic arithmetic
functionality in a user-friendly interface.

Conclusion
Creating a calculator in VB.NET is a great way to practice programming fundamentals while building a useful
tool.

20

You might also like