Я создаю программу, которая представляет собой список покупок, где пользователь нажимает на флажки и вставляет количество для каждого товара.Программа рассчитает стоимость, и если она будет меньше, чем бюджет, я хочу создать список с товаром и суммами.Как получить список для отображения на листе?
Вот код стоимости и бюджета:
Private Sub Begin_Click()
Dim FoodCost As Double
Dim Max As Double
Max = CDbl(Budget)
Try:
If Budget.Value = "" Then
MsgBox ("You must enter a budget for your shopping list")
Exit Sub
Else
FoodCost = 0
If TP.Value = True Then FoodCost = FoodCost + (5 * CDbl(TPquantity))
If Toothpaste.Value = True Then FoodCost = FoodCost + (3 * CDbl(ToothpasteQuantity))
If Shampoo.Value = True Then FoodCost = FoodCost + (7 * CDbl(shampooquantityQuantity))
If Tomato.Value = True Then FoodCost = FoodCost + (2 * CDbl(Tomatoquantity))
If Lettuce.Value = True Then FoodCost = FoodCost + (2 * CDbl(Lettucequantity))
If Avocado.Value = True Then FoodCost = FoodCost + (3 * CDbl(Avocadoquantity))
If Tomato.Value = True Then FoodCost = FoodCost + (2 * CDbl(Tomatoquantity))
If Milk.Value = True Then FoodCost = FoodCost + (6 * CDbl(MilkQuantity))
If Orangjuice.Value = True Then FoodCost = FoodCost + (7 * CDbl(OJquantity))
If Beer.Value = True Then FoodCost = FoodCost + (18 * CDbl(Beerquantity))
If Pasta.Value = True Then FoodCost = FoodCost + (3 * CDbl(Pastaquantity))
If Cereal.Value = True Then FoodCost = FoodCost + (6 * CDbl(Cerealquantity))
If Popcorn.Value = True Then FoodCost = FoodCost + (5 * CDbl(PopcornQuantity))
If Chicken.Value = True Then FoodCost = FoodCost + (12 * CDbl(Chickenquantity))
If Turkey.Value = True Then FoodCost = FoodCost + (8 * CDbl(TurkeyQuantity))
If Salmon.Value = True Then FoodCost = FoodCost + (15 * CDbl(SalmonQuantity))
Cost.Value = Format(FoodCost, "$#,##0.00")
End If
If Cost.Value > Max.Value Then
GoTo Catch
End If
Catch:
MsgBox ("You are over budget, please remove some items or change budget")
Exit Sub
End Sub
Это пользовательская форма