IS 51 Lab Exam 2 Guide

IS 51 Lab Exam 2 Guide - Simple Calculator/ Arithmetic...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Simple Calculator/ Arithmetic Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim sngNum1 As Single = Val(txtNum1.Text) Dim sngNum2 As Single = Val(txtNum2.Text) Dim op As String If radAdd.Checked Then op = "+" ElseIf radSubtract.Checked Then op = "-" ElseIf radMultiply.Checked Then op = "*" Else op = "/" End If Select Case op Case "+" txtResult.Text = sngNum1 + sngNum2 Case "-" txtResult.Text = sngNum1 - sngNum2 Case "*" txtResult.Text = sngNum1 * sngNum2 Case Else If sngNum2 = 0 Then txtResult.Text = "Please do not enter 0 as a value." Else txtResult.Text = sngNum1 / sngNum2 End If End Select End Sub Private Sub txtNum1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNum1.TextChanged End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click txtNum1.Text = " " txtNum2.Text = " " txtResult.Text = " " End Sub End Class Bagel Salad Soda Application Const Bagel As Single = 2.25 Const CreamCheese As Single = 1.0 Const Lox As Single = 1.2 Const Spinach As Single = 2.75 Const Chef As Single = 3.25 Const Cola As Single = 1.25 Const CreamSoda As Single = 1.25 Dim Total As Integer Private Sub chkBagel_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkBagel.CheckedChanged If chkBagel.Checked = True Then grpBagel.Visible = True If chkBagel.Checked = False Then grpBagel.Visible = False If chkBagel.Checked = False Then chkLox.Checked = False If chkBagel.Checked = False Then chkCC.Checked = False If chkBagel.Checked Then total = Bagel End If txtBagel.Text = FormatCurrency(Total) End Sub Private Sub chkSalad_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSalad.CheckedChanged If chkSalad.Checked = True Then grpSalad.Visible = True If chkSalad.Checked = False Then grpSalad.Visible = False Const Spinach As Single = 2.75 Const Chef As Single = 3.25 Dim total As Single If radSpinach.Checked Then total = Spinach End If If radChef.Checked Then total = Chef End If txtSalad.Text = FormatCurrency(total) End Sub Private Sub chkSoda_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSoda.CheckedChanged If chkSoda.Checked = True Then grpSoda.Visible = True If chkSoda.Checked = False Then grpSoda.Visible = False Const Cola As Single = 1.0 Const CreamSoda As Single = 1.0 Dim total As Single If radCola.Checked Then total = Cola End If...
View Full Document

This note was uploaded on 04/20/2008 for the course IS 51 taught by Professor Jung during the Spring '07 term at CSU Fresno.

Page1 / 11

IS 51 Lab Exam 2 Guide - Simple Calculator/ Arithmetic...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online