Lecture 5 Code Samples Eric J. Schwabe IT 236 Spring 2008
Lecture 5 Code Samples Eric J. Schwabe IT 236 Spring 2008
Eric J. Schwabe
IT 236 Spring 2008
=====
Option Strict On
' Reads the employee's name and type, and computes and displays their
' monthly salary appropriately when the type is S, H, or U. Displays
' an errors message for all other employee types.
name = txtName.Text
type = (txtType.Text).Trim
End Sub
Private Sub lstOutput_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lstOutput.SelectedIndexChanged
End Sub
End Class
=====
=====
' Cholesterol.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Demonstrates branching with if statements
' Read the user's cholesterol level from the text box, and check to see if it is okay
' (at most 200), slightly elevated (200-220), or considerable elevated (above 220).
' Give a appropriate reply in the label
' Constants for the cutoffs, and a variable to hold the input value
' Read in the user's value, and branch to give the appropriate reply
Try
cholesterol = Double.Parse(levelTextBox.Text)
Catch ex As Exception
End Try
End Sub
' Whenever the contents of the text box are modified, clear the label to insure that
' the text box cannot be changed to disagree witih the label
=====
=====
' LetterGrade.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Demonstrates the Case statement
Option Strict On
Debug.WriteLine(score)
gradeTextBox.Text = grade
Debug.WriteLine(grade)
End Sub
' Clear both text boxes when the user goes back to the input text box
gradeTextBox.Text = ""
scoreTextBox.Text = ""
End Sub
End Class
=====
=====
' Order.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Final branchign example
Option Strict On
' When the button is clicked, see which radio button is checked, and which check boxes
' are checked, and display the specified order and total
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles processButton.Click
If singleRadioButton.Checked Then
orderListBox.Items.Add("Single Burger")
total = 1.99
ElseIf doubleRadioButton.Checked Then
orderListBox.Items.Add("Double Burger")
total = 2.99
ElseIf tripleRadioButton.Checked Then
orderListBox.Items.Add("Triple Burger")
total = 3.99
End If
If cheeseCheckBox.Checked Then
orderListBox.Items.Add(" with Cheese")
total = total + 0.5
End If
If ketchupCheckBox.Checked Then
orderListBox.Items.Add(" with Ketchup")
End If
If mustardCheckBox.Checked Then
orderListBox.Items.Add(" with Mustard")
End If
End Sub
End Class
=====