0% found this document useful (0 votes)
263 views

Creating A Calculator Visual Studio C#

This document provides instructions for creating a basic calculator application in C# using Microsoft Visual Studio. It describes downloading and installing Visual Studio, creating a new project, designing the user interface, and adding functionality to handle number inputs and arithmetic operations.

Uploaded by

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

Creating A Calculator Visual Studio C#

This document provides instructions for creating a basic calculator application in C# using Microsoft Visual Studio. It describes downloading and installing Visual Studio, creating a new project, designing the user interface, and adding functionality to handle number inputs and arithmetic operations.

Uploaded by

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

let's make

Explore(/tag/typeid/)

Publish(/about/create.jsp)
Login(/account/login/) | SignUp(/account/gopro)

Classes NEW! (/classes/)


Featured: share what you make(/halloween/) (/halloween/)
(/id/intel/) IntelIoT(/id/intel/)
(/)
(/tag/typeid/categorytechnology/channelleds/) LEDs(/tag/typeid/categorytechnology/channelleds/)
(/tag/typeid/categorycostumes/) Costumes(/tag/typeid/categorycostumes/)

AboutThisInstructable

8 570,048 views
39 favorites

License:

cdog204
(/member/cdog204/)
Follow

12

(/member/cdog204/)
Morebycdog204:
(/file/FXG3AUMHS3GUN38/)
(/id/Creatinga

(/file/FHWSGEWHS3GUNOY/)

CalculatorVisualStudioC/)

ThisInstrucablewillguideyouthroughcreatingabasiccalculatorapplicationin
C#usingMicrosoft'sVisualStudodevelopmentsoftware.VisualStudioisa
formofdevelopmentsoftwaremadebyMicrosofttohelpdeveloperscreate
programsmoreeasily.Itisfreeandcanbedownloadedontheirwebsite.

Related

Whatyouwillneed:
AcomputerrunningWindows7orhigher

(/id/Howto

About30min1hroffreetime

HowtocreateaSplash
ScreeninC#VisualStudio
(/id/HowtocreateaSplash
ScreeninCVisualStudio/)
bySafeerAhmedAbro
CreatingYourFirstC++
ProgramusingtheVisual
StudioExpressIDE
(/id/CreatingYourFirstC

Possiblyascratchsheetofpaperforunderstandinglogic.
VisualStudio:
2013Download:http://www.visualstudio.com/enUS/products/visualstudio
expressvs
2010Download:http://msdn.microsoft.com/en
us/library/dd831853(v=vs.100).aspx
Iwillbeusingthe2010versionofVisualStudiointhistutorial,buteveryversion
isprettysimilar.
IfyouarefamiliarwiththeJavaprogramminglanguage,C#functionsvery
similarly.Thesyntaxisjustslightlydifferent.
Don'tworryifyouaren'tfamiliarwithprogramming.ThisInstructablewillguide
youthroughtheentireprocess.Allyouneedaresomeproblemsolvingskills!

Step1:Creatinganewproject

(/file/F21M6TLHSE93TQP/)

(/file/FVGULEWHSE93TSJ/)

(/file/F155LA5HSE942R3/)

OBJECTDETECTIONAND
TRACKINGUSINGOPENCV,
VISUALSTUDIOC++2010
ANDARDUINO(/id/OBJECT
(/id/OBJECT DETECTIONANDTRACKING

1.1.Afterdownloadingandinstalling,runVisualStudiosoitisopenonyour
computer.
1.2.Atthewelcomescreen,click"NewProject...,"ordothefollowing:File
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
>New>Project

Awindowshouldpopupaskingforsomebasicconfigurations.
Download

(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
11Steps
1.3.Select"VisualC#"intheInstalledTemplatesColumn.
h
.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

1.4.Next,select"WindowsFormsApplication"intherightcolumnandname
yourprojectinthenamefieldbelow.Ihavenamedmine"Calculator,"but
chooseanynameyoulike.
1.5.Aftercompletingalloftheabove,Click"OK"andletVisualStudiobuildthe
shellforyourprogram.Whenfinished,yourscreenshouldlooklikethelast
imageabove.
1.6.ClickSaveAll(thetriplesaveiconontopofthescreen)andmoveonto
step2!

Previous
Next(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
ViewAllSteps(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
Download

ADVERTISEMENT

Wehaveabenicecommentpolicy.

Pleasebepositiveandconstructive.

wIMadeit!

AddImages

PostComment

IMadeit!

Favorite

Share

WenJunT(/member/WenJunT)

amonthago

Reply

HowtoturnthewrittencodeintorealApp?

CreatingaCalculatorVisualStudioC# by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
2monthsago
shahzebHaider(/member/shahzebHaider)madeit!

Reply

Download

Justnotprogrammingbutdesigningalsomatter):p
11Steps
h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

(https://cdn.instructables.com/FEB/GPN0/ISCB8DE8/FEBGPN0ISCB8DE8.LARGE.jpg)

franka13(/member/franka13)madeit!

2monthsago

Reply

Thanks

(https://cdn.instructables.com/F9W/YUQA/IRXPQJBU/F9WYUQAIRXPQJBU.LARGE.jpg)

ambrosechinedu1(/member/ambrosechinedu1)

3monthsago

Reply

hithanksfortheinstructionsonbuildingabasiccalculator.Howeverinoticed
thatyourcodeonlymadeprovisionsforacceptingtwoinputsfromtheuser.how
wouldthecodelooklikeifiwantedtheusertoinputasmanyashewants?
thanks

BekeleG1(/member/BekeleG1)

3monthsago

Reply

3monthsago

Reply

howtochangethewrittenprogramtorealapplecation?

TaslimU(/member/TaslimU)

Calculatorthousandseparatorbycommainc#
privatevoidTextBox_TextChanged(objectsender,EventArgse)
{
stringvalue=TextBox.Text.Replace(",","")
longul
if(long.TryParse(value,outul))
{
TextBox.TextChanged=TextBoxTextChanged

Favorite

Share

TextBox.Text=string.Format("{0:#,#0}",ul)
TextBox.SelectionStart=TextBox.Text.Length
TextBox.TextChanged+=TextBoxTextChanged
CreatingaCalculatorVisualStudioC#
by
}
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
}

Download

IusedabovecodeformakingCalculator.Iwanttogetresultscommawith

11Steps
h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
decimalvaluebypressingequalbutton.NormallyIcantype1,234.1234inthe
IMadeit!
textBox,butifIpress1,234.1234+1,234.1234itdoesnotgivetheresult
Collection
2,468.2464itgivesresultonly2468.2468.Imeancommawithdecimalvalue
notgettingbypressingequal.

Couldyoukindlypleasehelpmetosolvethisproblem?

Cicless(/member/Cicless)

4monthsago

Reply

Hey,Ifinishedeverythingcorrectly(Ithink),butafterIcompiledmycodeandran
it,IpressedthedigitsandBOOM!Nothinghappened...:(Ithentriedadding
textBox1.Text=textBox1.Text+"(number)"
butunfortunately,stillnothing...Couldsomeonegladlyhelpme,please?:(

Abhirash(/member/Abhirash) . Cicless(/member/Cicless) 4monthsago

Reply

Ucouldtrythis....textBox.Text=textBox.Text+System.
Convert.ToString(6)similarforotherbuttonstoo

SabaNajeeb(/member/SabaNajeeb)

6monthsago

Reply

ThefirstproblemIencounteredwas,afterpressingF5mydigitswerenot
displayedinthetextboxtosolvethatiwrotethefollowinglinetodisplaydigit8
andsamegoesforeverybuttononthecalculator.:
textBox1.Text=textBox1.Text+"8"
ihavesuccessfullyimplementedeachstepbutmyoutputisnotbeing
displayed.
kindlyguideme.Thankyou

ValeanR(/member/ValeanR) . SabaNajeeb(/member/SabaNajeeb)

Reply

4monthsago

Hi,foryourprogramtoshownumbersuneed

textBox1.Text=textBox1.Text+(thebuttonnameinproprieties)
ex1:
textBox1.Text=textBox1.Text+btn8.Text(ifuwanttoprintnumber8
andsoonforallnumbers)

RobinS88(/member/RobinS88)

8monthsago

Reply

IgotitworkingbutdoesanyoneknowhowIcangetthistoworkwithmorethan
2numbers?forexample:1+1+1*2etc.

BrianG123(/member/BrianG123) . RobinS88(/member/RobinS88)

Favorite

Share

ThisisthechangeImadeto
Click_Subtract/Add/Multiply/Divide

7monthsago

Reply

ThisallowsThesetwoforms

CreatingaCalculatorVisualStudioC#
by
1+2+3+4+5+6=

cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)

or
Download

1+2=+3=+4=+5=+6=

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
Justtwoifstatements.

11Steps

AddingParenthesisisthetherealchallenge

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

Examplemethod:
privatevoidSubtract_Click(objectsender,RoutedEventArgse)
{
if(op1.Length!=0)
Enter_Click(sender,e)
if(input.Length==0)
input=result.ToString()
op1=input
operation=''
input=string.Empty
}

oldsoldier314.(/member/oldsoldier314.)

11monthsago

Reply

I'mrunningstudio2015andgeterrormessagesaboutdevariablesTextbox1
andText.Soican'ttestit.StudioadvicestousefortextBox1"privateobject
textBox1",butstilgeterrors.Thisisthedescription:
SeverityCodeDescriptionProjectFileLine
ErrorCS1061'object'doesnotcontainadefinitionfor'Text'andnoextension
method'Text'acceptingafirstargumentoftype'object'couldbefound(areyou
missingausingdirectiveoranassemblyreference?)
Thecodeuuseis"this.textBox1.Text",studiogivesadvicetouse
"textBox1.Text"soleavingThisout.
Canyouhelpmefurther?

arjoghosh(/member/arjoghosh) . oldsoldier314.(/member/oldsoldier314.)

VS2015hastextboxnottextbox1Checkit.:)

arjoghosh(/member/arjoghosh)

8monthsago

Reply

8monthsago

Reply

9monthsago

Reply

Ienjoyedthisprojectwork.:)

evalsam(/member/evalsam)madeit!

excellentwork,theapplicationisworkingperfectly.
justthatitcan'tperformoperationlike3+6.ifyoutrythisyouhave9
iwillworkonthisanyway

Favorite

Share

CreatingaCalculatorVisualStudioC# by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
Download
(https://cdn.instructables.com/FT4/LWAJ/IJQOMYL7/FT4LWAJIJQOMYL7.LARGE.jpg)
11Steps
.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

Collection
HamdanB(/member/HamdanB)

10monthsago

IMadeit!
Reply

Nicework....Butamfindingitdifficulttocalculateanything...thenumbersand
signsarenotcorrespondingtoeachother.WhenIdothis,forinstance,1and
thepressthemultiplicationsign(x),andthenpress8,itshows18...no
calculationsdone..Whatcouldbetheproblem?

MeMarieL(/member/MeMarieL) . HamdanB(/member/HamdanB)

Reply

9monthsago

Hi!Itlooksliketheprogramisaddingnumbersasatext
(string)notaregularnumber(f.ex.int).Itseesthenumberasletters.If
youconverttxtproperly,you'reproblemincodemaybewhereyoutypein
signoftheoperation.

Lithiil(/member/Lithiil)madeit!

ayearago

Reply

Imadethecalculatorprettyeasily.Theinstructionsareveryclearandwell
organized.Ievenaddeda"raisenumbertothepowerX"option.Thereisabug
inthecode...trytodo:2+2=itwillshowyou4nowpress+2=itwillshow
you4again,becauseitusesthelastinsertednumber...iamthinkingabouthow
tofixthis...butallmyattemptsareinvain.

(https://cdn.instructables.com/FWR/AAJ3/IGKQ60II/FWRAAJ3IGKQ60II.LARGE.jpg)

Derbucher(/member/Derbucher)madeit!

ayearago

Reply

ThanksforthefunC#Project,needtofindmorelikethis

(https://cdn.instructables.com/F1E/DEC5/IF6NO1LQ/F1EDEC5IF6NO1LQ.LARGE.jpg)

Favorite

Share

ayearago

gabeg3(/member/gabeg3)madeit!

Reply

CreatingaCalculatorVisualStudioC#
by
iranintoerrorsonTryparsebutthatwascauseiforgottoadda(dot)after
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
double.....,butieventuallygotallmyerrorsfixedthanksforthishelpfultutorial,

imabeginnertryingtolearntocode.

Download

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

(https://cdn.instructables.com/FTB/QS8J/IETSOQMV/FTBQS8JIETSOQMV.LARGE.jpg)

MuhammadS69(/member/MuhammadS69)

ayearago

Reply

ayearago

Reply

NICE

thibautb(/member/thibautb)

Thanksyouverymuch,reallyusefulandwellexplained.
Ihaveseenthatisbettertoreadallthetutorial(quickly)beforetostart.
Bestregards
T

TomB19(/member/TomB19)

ayearago

Reply

thedotisntworkingbyme1do1.1+0.1andhesaiditis12howtofixit

peter.onyegbule.7(/member/peter.onyegbule.7)

ayearago

Reply

2yearsago

Reply

GoodOneI'tryitout

connorc5(/member/connorc5)

Pleasehelpidoneeverythingbutitsaidihave102syntaxerrorscanuplease
helpthisisurgent
PublicClassForm1
stringinput=string.Empty
stringoperand1=string.Empty
stringoperand2=string.Empty
charoperation
doubleresult=0.0
}
PrivatePropertyoperand1AsObject
PrivatePropertyoperationAsObject
PrivateSubseven_Click(senderAsObject,eAsEventArgs)Handles
seven.Click

Favorite

Share

{
this.textBox2.Text=""
input+="7"
CreatingaCalculatorVisualStudioC#
by
this.textBox2.Text+=input
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
}

Download

EndSub

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)

PrivateSubeight_Click(senderAsObject,eAsEventArgs)Handleseight.Click
Collection

{
this.textBox2.Text=""
input+="8"
this.textBox2.Text+=input
}
EndSub
PrivateSubnine_Click(senderAsObject,eAsEventArgs)Handlesnine.Click
{
this.textBox2.Text=""
input+="9"
this.textBox2.Text+=input
}
EndSub
PrivateSubdivide_Click(senderAsObject,eAsEventArgs)Handles
divide.Click
{
operand1=input
operation='/'
input=string.Empty
}
EndSub
PrivateSubfour_Click(senderAsObject,eAsEventArgs)Handlesfour.Click
{
this.textBox2.Text=""
input+="4"
this.textBox2.Text+=input
}
EndSub
PrivateSubfive_Click(senderAsObject,eAsEventArgs)Handlesfive.Click
{
this.textBox2.Text=""
input+="5"
this.textBox2.Text+=input
}
EndSub

IMadeit!

Favorite

Share

PrivateSubsix_Click(senderAsObject,eAsEventArgs)Handlessix.Click
{
this.textBox2.Text=""
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
input+="6"

this.textBox2.Text+=input
Download
}

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
EndSub

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

PrivateSubmultiply_Click(senderAsObject,eAsEventArgs)Handles
multiply.Click
{
operand1=input
operation='*'
input=string.Empty
}
EndSub
PrivateSubone_Click(senderAsObject,eAsEventArgs)Handlesone.Click
{
this.textBox2.Text=""
input+="1"
this.textBox2.Text+=input
}
EndSub
PrivateSubtwo_Click(senderAsObject,eAsEventArgs)Handlestwo.Click
{
this.textBox2.Text=""
input+="2"
this.textBox2.Text+=input
}
EndSub
PrivateSubthree_Click(senderAsObject,eAsEventArgs)Handlesthree.Click
{
this.textBox2.Text=""
input+="3"
this.textBox2.Text+=input
}
EndSub
PrivateSubplus_Click(senderAsObject,eAsEventArgs)Handlesplus.Click
{
operand1=input
operation='+'
input=string.Empty
}

Favorite

Share

EndSub
PrivateSubzero_Click(senderAsObject,eAsEventArgs)Handleszero.Click
{
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
this.textBox2.Text=""

input+="0"
Download
this.textBox2.Text+=input

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
}

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

EndSub
PrivateSubdot_Click(senderAsObject,eAsEventArgs)Handlesdot.Click
{
this.textBox2.Text=""
input+="."
this.textBox2.Text+=input
}
EndSub
PrivateSubC_Click(senderAsObject,eAsEventArgs)HandlesC.Click
{
this.textBox2.Text=""
this.input=string.Empty
this.operand1=string.Empty
this.operand2=string.Empty
input+="C"
}
EndSub
PrivateSubtakeaway_Click(senderAsObject,eAsEventArgs)Handles
takeaway.Click
{
operand1=input
operation=''
input=string.Empty
}
EndSub
PrivateSubEquals_Click(senderAsObject,eAsEventArgs)Handles
Equals.Click
operand2=input
doublenum1,num2
double.TryParse(operand1,outnum1)
double.TryParse(operand2,outnum2)
if(operation=='+')
{
result=num1+num2
textBox1.Text=result.ToString("N")
}

IMadeit!

Favorite

Share

elseif(operation=='')
{
result=num1num2
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)

textBox1.Text=result.ToString("N")

Download
}

elseif(operation=='*')
h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

result=num1*num2
textBox1.Text=result.ToString("N")
}
elseif(operation=='/')
{
if(num2!=0)
{
result=num1/num2
textBox1.Text=result.ToString("N")
}
Else
{
textBox1.Text="DIV/Zero!"
}
{
this.textBox2.Text=""
input+="="
this.textBox2.Text+=input
}
EndSub
PrivateFunctioninput()AsObject
ThrowNewNotImplementedException
EndFunction
EndClass

scott.milella(/member/scott.milella)madeit!

2yearsago

ThiswasaverystraitforwardbutusefullessononC

(https://cdn.instructables.com/FEJ/A6GY/I7N5ZLIC/FEJA6GYI7N5ZLIC.LARGE.jpg)

Reply

Favorite

Share

AbdulrahmanR(/member/AbdulrahmanR)

2yearsago

Reply

ThanksAloteOPitwashardworkbutimanagedtounderstanditkeepitupbro

CreatingaCalculatorVisualStudioC#
by
:)

cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
Download
HiImEys(/member/HiImEys)
h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

Thanks:)

11Steps

2yearsago

Reply

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

UmerNaseer(/member/UmerNaseer)

2yearsago

IMadeit!

Reply

brotheryourworkisappreciateablebutthemistakeuhavedoneinthiscodeis
justasimplethingthatyouforgottodeclareresultvariableoftypedouble.:)
thankyouforyourhelpdearbrother:)

AhsanS(/member/AhsanS)

2yearsago

Reply

HelloSir!
FirstofallIwouldappreciateyoureffortforelaboratingtheapplicationso
beautifully,SecondlyIwouldliketoaddthat,thereisnoprocedurebeing
adopted/methodsbeingtaughthowtolinkthekeyboardwiththebuttonsof
calculator,itwouldhaveanadditionalthing.

Anywaysthanksforsuchnicetutorial.

Regards,
Ahsan

mael.geissler(/member/mael.geissler)madeit!

2yearsago

Reply

IhavecompletedtheCalculatorBUTitwontwork.
Wheneveristartiticanpressbuttonsandallthatstuffbutnonumberwillbe
showeninthetextbox...
Thecodeihavewrittenisthefollowing(tb=textbox1):
usingSystem
usingSystem.Collections.Generic
usingSystem.ComponentModel
usingSystem.Data
usingSystem.Drawing
usingSystem.Linq
usingSystem.Text
usingSystem.Windows.Forms
namespaceWindowsFormsApplication1
{

Favorite

Share

publicpartialclassForm1:Form
{
stringinput=string.Empty
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
stringoperand1=string.Empty

stringoperand2=string.Empty
Download
charoperation

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

doubleresult=0.0
publicForm1()
{

InitializeComponent()
}
privatevoidone_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="1"
this.tb.Text+=input
}
privatevoidtwo_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="2"
this.tb.Text+=input
}
privatevoidthree_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="3"
this.tb.Text+=input
}
privatevoidfour_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="4"
this.tb.Text+=input
}
privatevoidfive_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="5"
this.tb.Text+=input
}
privatevoidsix_Click(objectsender,EventArgse)

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

Favorite

Share

{
this.tb.Text=""
input+="6"
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
this.tb.Text+=input

}
Download
privatevoidseven_Click(objectsender,EventArgse)

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

this.tb.Text=""
input+="7"
this.tb.Text+=input
}
privatevoideight_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="8"
this.tb.Text+=input
}
privatevoidnine_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="9"
this.tb.Text+=input
}
privatevoidzero_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="0"
this.tb.Text+=input
}
privatevoiddot_Click(objectsender,EventArgse)
{
this.tb.Text=""
input+="."
this.tb.Text+=input
}
privatevoidplus_Click(objectsender,EventArgse)
{
operand1=input
operation='+'
input=string.Empty
}
privatevoidminus_Click(objectsender,EventArgse)

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

Favorite

Share

{
operand1=input
operation=''
CreatingaCalculatorVisualStudioC#
by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
input=string.Empty

}
Download
privatevoiddivide_Click(objectsender,EventArgse)

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

operand1=input
operation='/'
input=string.Empty
}
privatevoidstar_Click(objectsender,EventArgse)
{
operand1=input
operation='*'
input=string.Empty
}
privatevoidclr_Click(objectsender,EventArgse)
{
this.tb.Text=""
this.input=string.Empty
this.operand1=string.Empty
this.operand2=string.Empty
}
privatevoidequal_Click(objectsender,EventArgse)
{
operand2=input
doublenum1,num2
double.TryParse(operand1,outnum1)
double.TryParse(operand2,outnum2)
this.tb.Text=""
this.input=string.Empty
this.operand1=string.Empty
this.operand2=string.Empty
if(operation=='+')
{
result=num1+num2
tb.Text=result.ToString("N")
}
elseif(operation=='')
{
result=num1num2

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

Favorite

Share

tb.Text=result.ToString("N")
}
elseif(operation=='*')
CreatingaCalculatorVisualStudioC#
by
{
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
result=num1*num2

Download

tb.Text=result.ToString("N")

h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

elseif(operation=='/')
{
if(num2!=0)
{
result=num1/num2
tb.Text=result.ToString("N")
}
else
{
tb.Text="DIV/Zero!"
}
}
}
}
}
WhatmustichangetomaketheCalculatorwork?
undefined
(http://www.instructables.com/files/orig/FGC/5QZP/I1NEF20D/FGC5QZPI1NEF20D.null)

ConnorR3(/member/ConnorR3)

2yearsago

Reply

HowwouldIbeabletoaddSinCosandTanbuttons?AndisthereanywayI
couldcreateasquarerootsymbol?

MuhummadA(/member/MuhummadA)

2yearsago

Reply

howtoworkifiadd4+4+4showtheresultandkeeponaddingonplus
buttoninsteadofequalbuttonpleasesendlogic

itspureevil(/member/itspureevil)

2yearsago

Reply

Howdoifixtheproblemwhitthe'.',ienter1.3+0.3etheresultis16

emilsifu(/member/emilsifu) . itspureevil(/member/itspureevil)

Youmustreplace
textBox1.Text=result.ToString()

Reply

2yearsago

Favorite

Share

with
textBox1.Text=result.ToString("N")

CreatingaCalculatorVisualStudioC# by
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
2yearsago
nsanthosh28(/member/nsanthosh28)madeit!
Download

Reply

Hi,igotsimplecalculation,butwhilepressing2*=0(InwindowscalculatorEg:
11Steps
h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
2*=4andthenpressing=itwillgive8,16,32...)whatisthelogicplssend2me.
IMadeit!
Collection
mymailidnsanthosh28y@yahoo.com

Favorite

Share

(https://cdn.instructables.com/FHX/N8UB/HY4KRI2S/FHXN8UBHY4KRI2S.LARGE.jpg)

FEATURED CHANNELS

Woodworking

Paper

KitchenHacks

Puzzles

Space

IceCream

Homesteading

3DPrinting

Sewing

(/tag/type
id/category

(/tag/type
id/category

(/tag/type
id/keyword

(/tag/type
id/category

(/tag/type
id/keyword

(/tag/type
id/keyword

(/tag/type
id/category

(/tag/type
id/category

(/tag/type
id/category

workshop/channelcraft/channel kitchen%20hacks/?play/channel
astronomy/? ice%20cream/? home/channel technology/channel
craft/channel
woodworking/)
paper/)
sort=FAVORITES)
puzzles/)
sort=FAVORITES)sort=FAVORITES)homesteading/) 3DPrinting/)
sewing/)

Newsletter

Join2million+toreceiveinstant
DIYinspirationinyourinbox.
enteremail

I'min!

Mobile
Downloadourapps!
Android(https://play.google.com/store/apps/details?id=com.adsk.instructables)
iOS(https://itunes.apple.com/app/instructables/id586765571)
Windows(http://apps.microsoft.com/windows/enus/app/7afc8194c771441a959054250d6a8300)

AboutUs

FindUs

WhoWeAre(/about/)

Facebook(http://www.facebook.com/instructables)

Advertise(/advertise/)

Youtube(http://www.youtube.com/user/instructablestv)
by
Contact(/about/contact.jsp)
Twitter(http://www.twitter.com/instructables)
cdog204(/member/cdog204/)insoftware(/tag/typeid/categorytechnology/channelsoftware/)
Jobs(/community/PositionsavailableatInstructables/)
Pinterest(http://www.pinterest.com/instructables)
Help(/id/howtowriteagreatinstructable/)
Google+(https://plus.google.com/+instructables)
Download

CreatingaCalculatorVisualStudioC#

Resources
h(/id/CreatingaCalculatorVisualStudioC/?ALLSTEPS)
ForTeachers(/teachers/)
ArtistsinResidence(/air)

11Steps

.(/id/CreatingaCalculatorVisualStudioC/step2/DesigningtheApplication/)
Collection

IMadeit!

GiftPremiumAccount(/account/give?sourcea=footer)
Forums(/community/)
Answers(/tag/typequestion/?sort=RECENT)
Sitemap(/sitemap/)

TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(http://www.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2016Autodesk,Inc.

Favorite

Share

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy