【发布时间】:2015-10-15 14:08:55
【问题描述】:
我正在为我刚开始的 VB 课程创建一个披萨订购系统。我可以为披萨编写一个浇头,但是当我尝试添加一个以上的浇头时,我得到的项目有两个浇头,但还有另外两个只有一个浇头的披萨。如果在分组框中只选中了一定数量的复选框,有没有办法运行 if 语句?
Private Sub AddItems()
'Declare Topping Variables
Dim topping1 As String = "Pepperoni"
Dim topping2 As String = "Bacon"
Dim topping3 As String = "Ham"
'Declare Size Variables
Dim strPersonal As String = "Persoanl"
Dim strSmall As String = "Small"
Dim strMedium As String = "Medium"
Dim strLarge As String = "Large"
Dim strExLarge As String = "Extra Large"
'Personal Single Item
If radPersonal.Checked = True And chkPepperoni.Checked = True Then
CheckedListBox1.Items.Add(strPersonal & " with " & topping1)
End If
If radPersonal.Checked = True And chkBacon.Checked = True Then
CheckedListBox1.Items.Add(strPersonal & " with " & topping2)
End If
If radPersonal.Checked = True And chkHam.Checked = True Then
CheckedListBox1.Items.Add(strPersonal & " with " & topping3)
End If
'Personal Two Items
If radPersonal.Checked = True And chkPepperoni.Checked = True And chkBacon.Checked = True Then
CheckedListBox1.Items.Add(strPersonal & " with " & topping1 & " and " & topping2)
End If
If radPersonal.Checked = True And chkBacon.Checked = True And chkHam.Checked = True Then
CheckedListBox1.Items.Add(strPersonal & " with " & topping2 & " and " & topping3)
End If
If radPersonal.Checked = True And chkHam.Checked = True And chkPepperoni.Checked = True Then
CheckedListBox1.Items.Add(strPersonal & " with " & topping3 & " and " & topping1)
End If
End Sub
【问题讨论】: