SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Start Fresh Download from 	TPITVB.blogspot.com 2 1
Start fresh Start VS 2005 and Create a new project: Calculator_IT1C_xx Choose appropriate directory and remember its path Exit VS 2005 Unzip start_cal.zip: Form1.vb and Form1.Designer.vb Use File explorer to replace the two newly created project files in Calculator_IT1C_xx
ButtonSqrt_Click Double click on the button for Sqrt to generate the ButtonSqrt_Click subroutine Copy the codes from ButtonEqual_Click Modify the following line to use Math.Sqrt 		total = total + x 		total = Math.Sqrt(x)
ButtonPercent_Click Double click on the button for % to generate the ButtonPercent_Click subroutine Copy the codes from ButtonEqual_Click Modify the following line to use Math.Sqrt 		total = total + x 		total = x / 100
Dot Private Sub ButtonDot_Click ‘ Copy the codes from Button0 ‘ Replace “0”  with “.”  	Dim existingString As String = TextBox1.Text  	If existingString <> "" Then    	 	TextBox1.Text = existingString & "0"  	End If End Sub “.”
Testing 1.5  OK 0.5  NG  => How?
Dot Private Sub ButtonDot_Click ‘ Add else condition ‘ to add “0.”    Dim existingString As String = TextBox1.Text    If existingString <> "" Then       TextBox1.Text = existingString & “.”    End If End Sub   Else TextBox1.Text = existingString & “0.”  End If End Sub
Testing 1.5  OK 0.5  OK 1.5.5.  => should not allow – How?
How to stop “1.5.5.”? We need to use a global variable to track if “.” has been set  Then add additional codes in ButtonDot to check this variable
Dot Global variable: Public Class Form1 Dim isDotted As Boolean = False
Dot Private Sub ButtonDot_Click ‘ Add Condition to check for isDotted Dim existingString As String = TextBox1.Text If existingString <> "" Then TextBox1.Text = existingString & “.”    Else TextBox1.Text = existingString & “0.”     End If End Sub If  isDotted = False  Then isDotted= True      ‘ Set isDotted to True    End If End Sub
Testing 1.5  OK 0.5  OK 1.5.5. OK 1.5  Clear  1.5  => NG - How?
Dot Private Sub ButtonClear_Click 		: 		: 	‘ Reset isDotted to False isDotted = False End Sub
Testing 1.5  OK 0.5  OK 1.5.5. OK 1.5  Clear  1.5  OK 1.5 + 1.5 => NG – How?
Dot Private Sub ButtonPlus_Click 			: 			: 	‘ Reset isDotted to False isDotted = False End Sub
Testing 1.5  OK 0.5  OK 1.5.5. OK 1.5  Clear  1.5  OK 1.5 + 1.5 OK Anymore cases?
Minus, Multiply and Divide Before we proceed to add the processing for Minus, Multiply and Divide, we need to modify the current processing for Plus and Equal
Modify Plus and Equal Private Sub ButtonPlus_Click 			: 			: 	total  =   total  +  x 			: End  Sub total  =  x		‘  Now, Plus can only be 				‘  pressed once.
Modify Plus and Equal Global variable: Public Class Form1 	Dim  whatFunction  As  String  =  “None”
Modify Plus and Equal Private Sub ButtonPlus_Click 			: 			: whatFunction = “Plus” End  Sub
Modify Plus and Equal Private Sub ButtonEqual_Click 			: 			: 	total = total + x 			: End  Sub Select  Case  whatFunction Case  “Plus”    		total  =  total + x End Select Case  “Minus”
Add Minus, Multiply and Divide Complete the processing for minus, multiply and divide. Take care of divide by zero error with if then else statement Do testingand debugging to take care of other errors

Weitere ähnliche Inhalte

Was ist angesagt? (6)

Providing sl no in Gridview in Dot Net
Providing sl no in Gridview in Dot NetProviding sl no in Gridview in Dot Net
Providing sl no in Gridview in Dot Net
 
Web services in asp.net
Web services in asp.netWeb services in asp.net
Web services in asp.net
 
Keyboard shortcut - Phím tắt hệ điều hành windows 10
Keyboard shortcut - Phím tắt hệ điều hành windows 10Keyboard shortcut - Phím tắt hệ điều hành windows 10
Keyboard shortcut - Phím tắt hệ điều hành windows 10
 
How to add sql server table into dot net web page (Gridview)
How to add sql server table into dot net web page (Gridview)How to add sql server table into dot net web page (Gridview)
How to add sql server table into dot net web page (Gridview)
 
How to add sorting and pagers to grid view
How to add sorting and pagers to grid viewHow to add sorting and pagers to grid view
How to add sorting and pagers to grid view
 
Bd1 erdenejargal b 2
Bd1 erdenejargal b 2Bd1 erdenejargal b 2
Bd1 erdenejargal b 2
 

Ähnlich wie Calculator Processing

Calculator 4
Calculator 4Calculator 4
Calculator 4
livecode
 
Delphi L08 Controls at Runtime P2
Delphi L08 Controls at Runtime P2Delphi L08 Controls at Runtime P2
Delphi L08 Controls at Runtime P2
Mohammad Shaker
 
Ankit Phadia Hacking tools (1)
Ankit Phadia Hacking tools (1)Ankit Phadia Hacking tools (1)
Ankit Phadia Hacking tools (1)
Chandra Pr. Singh
 
Calculator 5
Calculator 5Calculator 5
Calculator 5
livecode
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
Vince Vo
 
Gui builder
Gui builderGui builder
Gui builder
learnt
 

Ähnlich wie Calculator Processing (20)

Calculator 4
Calculator 4Calculator 4
Calculator 4
 
Delphi L08 Controls at Runtime P2
Delphi L08 Controls at Runtime P2Delphi L08 Controls at Runtime P2
Delphi L08 Controls at Runtime P2
 
Cognos TM1 Assignments
Cognos TM1 Assignments Cognos TM1 Assignments
Cognos TM1 Assignments
 
C# Loops
C# LoopsC# Loops
C# Loops
 
Devry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting startedDevry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting started
 
Devry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting startedDevry cis 170 c i lab 1 of 7 getting started
Devry cis 170 c i lab 1 of 7 getting started
 
Ankit Phadia Hacking tools (1)
Ankit Phadia Hacking tools (1)Ankit Phadia Hacking tools (1)
Ankit Phadia Hacking tools (1)
 
Steps how to do cmd
Steps how to do cmdSteps how to do cmd
Steps how to do cmd
 
Numerical modeling of concrete in Abaqus
Numerical modeling of concrete in Abaqus Numerical modeling of concrete in Abaqus
Numerical modeling of concrete in Abaqus
 
Calculator 5
Calculator 5Calculator 5
Calculator 5
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Tutorials.pdf
Tutorials.pdfTutorials.pdf
Tutorials.pdf
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Web Server Controls CS Set
Web Server Controls CS Set Web Server Controls CS Set
Web Server Controls CS Set
 
Cpp Homework Help
Cpp Homework Help Cpp Homework Help
Cpp Homework Help
 
Cookbook Oracle SOA Business Rules
Cookbook Oracle SOA Business RulesCookbook Oracle SOA Business Rules
Cookbook Oracle SOA Business Rules
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Ankit Phadia Hacking tools
Ankit Phadia Hacking toolsAnkit Phadia Hacking tools
Ankit Phadia Hacking tools
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Gui builder
Gui builderGui builder
Gui builder
 

Mehr von Hock Leng PUAH

CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
 
Connectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe ProjectConnectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe Project
Hock Leng PUAH
 

Mehr von Hock Leng PUAH (20)

ASP.net Image Slideshow
ASP.net Image SlideshowASP.net Image Slideshow
ASP.net Image Slideshow
 
Visual basic asp.net programming introduction
Visual basic asp.net programming introductionVisual basic asp.net programming introduction
Visual basic asp.net programming introduction
 
Using iMac Built-in Screen Sharing
Using iMac Built-in Screen SharingUsing iMac Built-in Screen Sharing
Using iMac Built-in Screen Sharing
 
Hosting SWF Flash file
Hosting SWF Flash fileHosting SWF Flash file
Hosting SWF Flash file
 
PHP built-in functions date( ) and mktime( ) to calculate age from date of birth
PHP built-in functions date( ) and mktime( ) to calculate age from date of birthPHP built-in functions date( ) and mktime( ) to calculate age from date of birth
PHP built-in functions date( ) and mktime( ) to calculate age from date of birth
 
PHP built-in function mktime example
PHP built-in function mktime examplePHP built-in function mktime example
PHP built-in function mktime example
 
A simple php exercise on date( ) function
A simple php exercise on date( ) functionA simple php exercise on date( ) function
A simple php exercise on date( ) function
 
Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web site
 
Responsive design
Responsive designResponsive design
Responsive design
 
Step by step guide to use mac lion to make hidden folders visible
Step by step guide to use mac lion to make hidden folders visibleStep by step guide to use mac lion to make hidden folders visible
Step by step guide to use mac lion to make hidden folders visible
 
Beautiful web pages
Beautiful web pagesBeautiful web pages
Beautiful web pages
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
 
Connectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe ProjectConnectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe Project
 
Logic gate lab intro
Logic gate lab introLogic gate lab intro
Logic gate lab intro
 
Ohm's law, resistors in series or in parallel
Ohm's law, resistors in series or in parallelOhm's law, resistors in series or in parallel
Ohm's law, resistors in series or in parallel
 
Connections Exercises Guide
Connections Exercises GuideConnections Exercises Guide
Connections Exercises Guide
 
Design to circuit connection
Design to circuit connectionDesign to circuit connection
Design to circuit connection
 
NMS Media Services Jobshet 1 to 5 Summary
NMS Media Services Jobshet 1 to 5 SummaryNMS Media Services Jobshet 1 to 5 Summary
NMS Media Services Jobshet 1 to 5 Summary
 
Virtualbox step by step guide
Virtualbox step by step guideVirtualbox step by step guide
Virtualbox step by step guide
 
Nms chapter 01
Nms chapter 01Nms chapter 01
Nms chapter 01
 

Kürzlich hochgeladen

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Kürzlich hochgeladen (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

Calculator Processing

  • 1. Start Fresh Download from TPITVB.blogspot.com 2 1
  • 2. Start fresh Start VS 2005 and Create a new project: Calculator_IT1C_xx Choose appropriate directory and remember its path Exit VS 2005 Unzip start_cal.zip: Form1.vb and Form1.Designer.vb Use File explorer to replace the two newly created project files in Calculator_IT1C_xx
  • 3. ButtonSqrt_Click Double click on the button for Sqrt to generate the ButtonSqrt_Click subroutine Copy the codes from ButtonEqual_Click Modify the following line to use Math.Sqrt total = total + x total = Math.Sqrt(x)
  • 4. ButtonPercent_Click Double click on the button for % to generate the ButtonPercent_Click subroutine Copy the codes from ButtonEqual_Click Modify the following line to use Math.Sqrt total = total + x total = x / 100
  • 5. Dot Private Sub ButtonDot_Click ‘ Copy the codes from Button0 ‘ Replace “0” with “.” Dim existingString As String = TextBox1.Text If existingString <> "" Then TextBox1.Text = existingString & "0" End If End Sub “.”
  • 6. Testing 1.5 OK 0.5 NG => How?
  • 7. Dot Private Sub ButtonDot_Click ‘ Add else condition ‘ to add “0.” Dim existingString As String = TextBox1.Text If existingString <> "" Then TextBox1.Text = existingString & “.” End If End Sub Else TextBox1.Text = existingString & “0.” End If End Sub
  • 8. Testing 1.5 OK 0.5 OK 1.5.5. => should not allow – How?
  • 9. How to stop “1.5.5.”? We need to use a global variable to track if “.” has been set Then add additional codes in ButtonDot to check this variable
  • 10. Dot Global variable: Public Class Form1 Dim isDotted As Boolean = False
  • 11. Dot Private Sub ButtonDot_Click ‘ Add Condition to check for isDotted Dim existingString As String = TextBox1.Text If existingString <> "" Then TextBox1.Text = existingString & “.” Else TextBox1.Text = existingString & “0.” End If End Sub If isDotted = False Then isDotted= True ‘ Set isDotted to True End If End Sub
  • 12. Testing 1.5 OK 0.5 OK 1.5.5. OK 1.5 Clear 1.5 => NG - How?
  • 13. Dot Private Sub ButtonClear_Click : : ‘ Reset isDotted to False isDotted = False End Sub
  • 14. Testing 1.5 OK 0.5 OK 1.5.5. OK 1.5 Clear 1.5 OK 1.5 + 1.5 => NG – How?
  • 15. Dot Private Sub ButtonPlus_Click : : ‘ Reset isDotted to False isDotted = False End Sub
  • 16. Testing 1.5 OK 0.5 OK 1.5.5. OK 1.5 Clear 1.5 OK 1.5 + 1.5 OK Anymore cases?
  • 17. Minus, Multiply and Divide Before we proceed to add the processing for Minus, Multiply and Divide, we need to modify the current processing for Plus and Equal
  • 18. Modify Plus and Equal Private Sub ButtonPlus_Click : : total = total + x : End Sub total = x ‘ Now, Plus can only be ‘ pressed once.
  • 19. Modify Plus and Equal Global variable: Public Class Form1 Dim whatFunction As String = “None”
  • 20. Modify Plus and Equal Private Sub ButtonPlus_Click : : whatFunction = “Plus” End Sub
  • 21. Modify Plus and Equal Private Sub ButtonEqual_Click : : total = total + x : End Sub Select Case whatFunction Case “Plus” total = total + x End Select Case “Minus”
  • 22. Add Minus, Multiply and Divide Complete the processing for minus, multiply and divide. Take care of divide by zero error with if then else statement Do testingand debugging to take care of other errors