Thursday, December 15, 2011

MENU SELECTOR

1. Create the user interface similar to the form below. Use PictureBox controls (picMeal, picBurger,picPizza,picCake,picDrinks,picDessert), CheckBox, RadioButton, ListBox and ComboBox within the GroupBox.



2. Enter the program code below by double clicking the form object.


Public Class frmMenuSelector

Private Sub frmMenuSelector_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

lstDrinks.Items.Add("Juice")
lstDrinks.Items.Add("Coffee")
lstDrinks.Items.Add("Softdrinks")
cboDessert.Items.Add("Ice Cream")
cboDessert.Items.Add("Salad")
cboDessert.Items.Add("Pastry")
End Sub

Private Sub cboDessert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDessert.Click

Select Case cboDessert.SelectedIndex
Case 0
picDessert.Image = My.Resources.Ice_cream
Case 1
picDessert.Image = My.Resources.Salad
Case 2
picDessert.Image = My.Resources.Pastry
End Select
End Sub

Private Sub chkBurger_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkBurger.Click

If chkBurger.Checked Then
picBurger.Image = My.Resources.Burger
picBurger.Visible = True
Else
picBurger.Visible = False
End If
End Sub

Private Sub chkCake_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkCake.Click

If chkCake.Checked Then
picCake.Image = My.Resources.Cake
picCake.Visible = True
Else
picCake.Visible = False
End If
End Sub

Private Sub chkPizza_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkPizza.Click

If chkPizza.Checked Then
picPizza.Image = My.Resources.Pizza
picPizza.Visible = True
Else
picPizza.Visible = False
End If
End Sub

Private Sub lstDrinks_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstDrinks.Click

Select Case lstDrinks.SelectedIndex
Case 0
picDrinks.Image = My.Resources.Juice
Case 1
picDrinks.Image = My.Resources.Coffee
Case 2
picDrinks.Image = My.Resources.Softdrinks
End Select
End Sub

Private Sub rdoChicken_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoChicken.Click

If rdoChicken.Checked Then
picMeal.Image = My.Resources.Chicken
picMeal.Visible = True
Else
picMeal.Visible = False
End If
End Sub

Private Sub rdoFish_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoFish.Click

If rdoFish.Checked Then
picMeal.Image = My.Resources.Fish
picMeal.Visible = True
Else
picMeal.Visible = False
End If
End Sub

Private Sub rdoPork_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdoPork.Click

If rdoPork.Checked Then
picMeal.Image = My.Resources.Pork
picMeal.Visible = True
Else
picMeal.Visible = False
End If

End Sub
End Class


3. Save and run your program. The program looks like below.




~You can use the photos below.....










No comments:

Post a Comment