Documente Academic
Documente Profesional
Documente Cultură
Eric J. Schwabe
IT 236 Spring 2008
=====
' Comparisons.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Display the result of various numerical and string comparisons
Option Strict On
Dim X, Y As String
X = xTextBox.Text()
Y = yTextBox.Text()
'Later...
'Dim X, Y As Double
'X = Double.Parse(xTextBox.Text)
'Y = Double.Parse(yTextBox.Text)
displayListBox.Items.Clear()
displayListBox.Items.Add(X & " = " & Y & " : " & (X = Y))
displayListBox.Items.Add("")
displayListBox.Items.Add(X & " <> " & Y & " : " & (X <> Y))
displayListBox.Items.Add("")
displayListBox.Items.Add(X & " < " & Y & " : " & (X < Y))
displayListBox.Items.Add("")
displayListBox.Items.Add(X & " <= " & Y & " : " & (X <= Y))
displayListBox.Items.Add("")
displayListBox.Items.Add(X & " > " & Y & " : " & (X > Y))
displayListBox.Items.Add("")
displayListBox.Items.Add(X & " >= " & Y & " : " & (X >= Y))
End Sub
End Class
=====
=====
' CompoundComparisons.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Demonstrate compound conditions using logical operators
Option Strict On
' Checks if an input exam score is legal (in range from 0 to 100)
' and if it is either very low (<65) or very high (>90)
displayListBox.Items.Clear()
displayListBox.Items.Add("Is " & score & " between 0 and 100?")
displayListBox.Items.Add((score >= 0) And (score <= 100))
displayListBox.Items.Add("")
displayListBox.Items.Add("Is " & score & " below 65 or above 90?")
displayListBox.Items.Add((score < 65) Or (score > 90))
'Dim a As Integer = 2
'Dim b As Integer = 3
'displayListBox.Items.Add("")
'displayListBox.Items.Add(3 * a = 2 * b)
'displayListBox.Items.Add((5 - a) * b < 7)
'displayListBox.Items.Add((a < b) And (b < a))
'displayListBox.Items.Add((a < b) Or (b < a))
'displayListBox.Items.Add((a * a) < b Xor (a * a) < a)
'displayListBox.Items.Add("car" < "train")
'displayListBox.Items.Add("Inspector" <= "guard")
'displayListBox.Items.Add(Not ("B" = "b"))
'displayListBox.Items.Add("pick" > "pitcher")
End Sub
End Class
=====
=====
' SSTax.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Uses branching to compute social security tax for a given income
Option Strict On
' When the button is clicked, the user's income is read from a
' text box and converted to a Double. If the value is at most
' maxIncome, the tax is taxRate times the income. If the value is
' more than maxIncome, the tax is taxRate times maxIncome.
income = Double.Parse(incomeTextBox.Text)
incomeTextBox.Text = income.ToString("C")
taxTextBox.Text = ssTax.ToString("C")
End Sub
End Class
=====
=====
' HiLoGame.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' The user tries to guess a randomly-generated number between 1 and 100
Option Strict On
End Sub
' Given a user's guess in the text box, first check that is in
' the range from 1 to 100. If it is, state whether the guess is
' too low, too high, or correct.
replyTextBox.Text = reply
End Sub
=====
=====
Option Strict On
txtGrade.Text = grade
End Sub
=====
=====
' Envelope.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Do input validation while constructing the mailing address for an envelope
' Read the contents of the text boxes, and address the envelope as long as all of the
' required fields have been filled in. Also check if the optional fields have been
filled
' in, and if they have not, omit them from the address.
firstName = firstTextBox.Text
middleName = middleTextBox.Text
lastName = lastTextBox.Text
address = addressTextBox.Text
city = cityTextBox.Text
state = stateTextBox.Text
zip = zipMaskedTextBox.Text
envelopeListBox.Items.Clear()
envelopeListBox.Items.Add("DePaul CDM")
envelopeListBox.Items.Add("243 S. Wabash Ave.")
envelopeListBox.Items.Add("Chicago, IL 60604")
envelopeListBox.Items.Add("")
envelopeListBox.Items.Add("")
Else
MessageBox.Show("Some required field has not been filled in.", "Error")
End If
End Sub
End Class
=====
=====
' Headshot.sln
' Eric J. Schwabe
' IT 236 Spring 2008
' Demonstrate the independent checking of several check boxes with if statements
' When any of the first four check boxes are changed, check each one and display the
picture,
' name, address, and email depending on which are checked. If either the address or
email
' check boxes are checked, enable the highlighting check box
End Sub
' If the highlighting check box is on, display the address and email in red,
' and if it is not, display them in black
=====