Saturday, October 4, 2008
Saturday, September 27, 2008
Exercises today:
Asking a user for info that will be useful in making a dating application!
You will need a(n):
You will need a(n):
- Checkbox
- ComboBox
- Labels
You need to ask the user for some information about themselves and quanitify it! Make a scale of compatibility for two people. You will ask the same questions of two people on the same form.
Give them back a percetage and a memorable saying!
Here's my code for the Love Tester!
'When you click the button:
Dim love As Integer = 0
If (CheckBox1.Checked And CheckBox2.Checked) Then
love = love + 5
ElseIf CheckBox1.Checked Then
love = love - 2
End If
If TextBox1.Text.Length = TextBox2.Text.Length Then
love = love + 100
End If
If ComboBox1.SelectedItem = "Running" And ComboBox2.SelectedItem = "Running" Then
love = love + 11
End If
If love > 50 Then
lblLove.Text = "You are a good match " & love
ElseIf love > 20 Then
lblLove.Text = "You are an okay match " & love
Else
lblLove.Text = "You should run! " & love
End If
Dim love As Integer = 0
If (CheckBox1.Checked And CheckBox2.Checked) Then
love = love + 5
ElseIf CheckBox1.Checked Then
love = love - 2
End If
If TextBox1.Text.Length = TextBox2.Text.Length Then
love = love + 100
End If
If ComboBox1.SelectedItem = "Running" And ComboBox2.SelectedItem = "Running" Then
love = love + 11
End If
If love > 50 Then
lblLove.Text = "You are a good match " & love
ElseIf love > 20 Then
lblLove.Text = "You are an okay match " & love
Else
lblLove.Text = "You should run! " & love
End If
Student Grader
- GUI Based
- Ask User for a grade (number from 0-100)
- Give the project a letter grade based on an if and else if series of conditions
- Add a check box for extra credit, if selected add an extra 5 points to their grade!
- A >= 90
- B >= 80
- C >= 70
- D >= 60
- F < "60"
Error Checking with isNumeric
Dim distance As Decimal = 0
Dim gallonsused As Decimal = 0
Dim mpg As Decimal = 0
If IsNumeric(Textgas.Text) = True And IsNumeric(Textmiles.Text) = True Then distance = Textmiles.Text
gallonsused = Textgas.Text
mpg = distance / gallonsused
Math.Round(mpg, 2)
mpgdisplay.Text = (mpg & " is your miles per gallon (mpg)")
Dim alertvariable As String = "Alert you are a gas guzzler!!!"
If mpg < 10 Then
alertlabel.Text = alertvariable
End If
If gallonsused > 50 Then
lblgasused.Text = ("you are using too much gas")
Else
MsgBox("You messed up. Gotta enter numbers")
End If
Else
MsgBox("Enter numbers")
Textmiles.Text = ""
Textgas.Text = ""
End If
Dim gallonsused As Decimal = 0
Dim mpg As Decimal = 0
If IsNumeric(Textgas.Text) = True And IsNumeric(Textmiles.Text) = True Then distance = Textmiles.Text
gallonsused = Textgas.Text
mpg = distance / gallonsused
Math.Round(mpg, 2)
mpgdisplay.Text = (mpg & " is your miles per gallon (mpg)")
Dim alertvariable As String = "Alert you are a gas guzzler!!!"
If mpg < 10 Then
alertlabel.Text = alertvariable
End If
If gallonsused > 50 Then
lblgasused.Text = ("you are using too much gas")
Else
MsgBox("You messed up. Gotta enter numbers")
End If
Else
MsgBox("Enter numbers")
Textmiles.Text = ""
Textgas.Text = ""
End If
Subscribe to:
Posts (Atom)