I need some help with my school project. I have 3 of them so I may be back on later. Basically I have 2 list boxes, one on the main form to select a dorm, then one on the second form to select a meal plan. When I select them and hit calculate, enter, etc, it supposed to put the total in the main form. Here is my code so far. Anyone have any suggestions?
Main Form:
Public Class MainForm1
Private Sub btnSelectMeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectMeal.Click
frmMealPlans.Show()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim AllenHall As Integer = 1500
Dim PikeHall As Integer = 1600
Dim FarthingHall As Integer = 1200
Dim UniversitySuites As Integer = 1800
Dim dormResults As Integer
If ListBox1.SelectedIndex = -1 Then
MessageBox.Show("Select a dorm!", "Error")
End If
If ListBox1.SelectedIndex = 0 Then
lblDormCost.Text = AllenHall.ToString
dormResults = AllenHall
ElseIf ListBox1.SelectedIndex = 1 Then
lblDormCost.Text = PikeHall.ToString
dormResults = PikeHall
ElseIf ListBox1.SelectedIndex = 2 Then
lbldormcost.Text = FarthingHall.ToString
dormResults = FarthingHall
ElseIf ListBox1.SelectedIndex = 3 Then
lbldormcost.Text = UniversitySuites.ToString
dormResults = UniversitySuites
End If
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
ListBox1.ClearSelected()
End Sub
End Class
Second Form:
Public Class frmMealPlans
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
ListBox1.ClearSelected()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim Meal7 As Integer = 560
Dim Meal14 As Integer = 1095
Dim Unlimited As Integer = 1500
Dim Results As Integer
If ListBox1.SelectedIndex = -1 Then
MessageBox.Show("Select a Meal Plan", "Error")
End If
If ListBox1.SelectedIndex = 0 Then
Results = Meal7
ElseIf ListBox1.SelectedIndex = 1 Then
Results = Meal14
ElseIf ListBox1.SelectedIndex = 2 Then
Results = Unlimited
End If
MainForm1.lbldormcost.Text = CStr(MainForm1.dormResults + Results)
End Sub
End Class
I basically just doesn't do what I need it to do. Thanks.
Main Form:
Public Class MainForm1
Private Sub btnSelectMeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectMeal.Click
frmMealPlans.Show()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim AllenHall As Integer = 1500
Dim PikeHall As Integer = 1600
Dim FarthingHall As Integer = 1200
Dim UniversitySuites As Integer = 1800
Dim dormResults As Integer
If ListBox1.SelectedIndex = -1 Then
MessageBox.Show("Select a dorm!", "Error")
End If
If ListBox1.SelectedIndex = 0 Then
lblDormCost.Text = AllenHall.ToString
dormResults = AllenHall
ElseIf ListBox1.SelectedIndex = 1 Then
lblDormCost.Text = PikeHall.ToString
dormResults = PikeHall
ElseIf ListBox1.SelectedIndex = 2 Then
lbldormcost.Text = FarthingHall.ToString
dormResults = FarthingHall
ElseIf ListBox1.SelectedIndex = 3 Then
lbldormcost.Text = UniversitySuites.ToString
dormResults = UniversitySuites
End If
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
ListBox1.ClearSelected()
End Sub
End Class
Second Form:
Public Class frmMealPlans
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
ListBox1.ClearSelected()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim Meal7 As Integer = 560
Dim Meal14 As Integer = 1095
Dim Unlimited As Integer = 1500
Dim Results As Integer
If ListBox1.SelectedIndex = -1 Then
MessageBox.Show("Select a Meal Plan", "Error")
End If
If ListBox1.SelectedIndex = 0 Then
Results = Meal7
ElseIf ListBox1.SelectedIndex = 1 Then
Results = Meal14
ElseIf ListBox1.SelectedIndex = 2 Then
Results = Unlimited
End If
MainForm1.lbldormcost.Text = CStr(MainForm1.dormResults + Results)
End Sub
End Class
I basically just doesn't do what I need it to do. Thanks.