안녕하세요 누군가 나를 도와주세요. 저는 사용자가 선택한 항목의 가격을 계산하기위한 시각적 기본 기능을 작성했습니다. If else if 루프를 사용했지만 첫번째 부분 만 출력을 표시합니다. 첫 번째 확인란을 선택하고 주문 버튼을 클릭하면 영수증에 가격과 선택한 항목이 채워지지만 선택하려면 확인란을 사용하고 있지만 두 번째, 세 번째 ... 확인란에 대해서는 발생하지 않습니다. 무엇이 잘못 될 수 있습니까? 여기 도와주세요 누군가가 기능Visual basic 만약 elseIf가 작동하지 않는다면
Private Sub computeCurrentSelection()
If chkugalis.Checked = True Then 'ugali fish selected
orderAmt = lab.Text
total = ugalif * orderAmt
subtotal = total
lstReceipt.Items.Add(orderAmt & " plates of" & " Ugali n fish " & total & " Kshs")
ElseIf chkGitheri.Checked = True Then 'ugali dengu slected
orderAmt = lab3.Text
total = ugalid * orderAmt
lstReceipt.Items.Add(orderAmt & " plates of " & "Ugali n dengu " & total)
ElseIf chkUgaliB.Checked = True Then 'githeri selected
orderAmt = lab2.Text
total = githeri * orderAmt
lstReceipt.Items.Add(orderAmt & " plates of " & "Githeri " & total)
ElseIf chkPilau.Checked = True Then
orderAmt = lab4.Text
total = chapo * orderAmt
lstReceipt.Items.Add(orderAmt & " plates of " & "Pilau " & total)
ElseIf chkPizza.Checked = True Then
orderAmt = lab5.Text
total = pilau * orderAmt
lstReceipt.Items.Add(orderAmt & " plates of " & "Pizza " & total)
ElseIf chkMandazi.Checked = True Then
orderAmt = lab6.Text
total = pizza * orderAmt
lstReceipt.Items.Add(orderAmt & "mandazi " & total)
ElseIf chkSamosa.Checked = True Then
orderAmt = lab7.Text
total = mandazi * orderAmt
lstReceipt.Items.Add(orderAmt & "Samosa " & total)
ElseIf chkChapon.Checked = True Then
orderAmt = lab8.Text
total = samosa * orderAmt
lstReceipt.Items.Add(orderAmt & "Chapati " & total)
ElseIf chkWater.Checked = True And chk300ml.Checked = True Then
orderAmt = lab9.Text
total = water1 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 300ml" & "Water " & total)
ElseIf chkWater.Checked = True And chk500ml.Checked = True Then
orderAmt = lab9.Text
total = water2 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 500ml" & "Water " & total)
ElseIf chkWater.Checked = True And chk1l.Checked = True Then
orderAmt = lab9.Text
total = water3 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 1l" & "Water " & total)
ElseIf chkWater.Checked = True And chk2l.Checked = True Then
orderAmt = lab9.Text
total = water4 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 2l" & "Water " & total)
ElseIf chkSoda.Checked = True And chk300ml.Checked = True Then
orderAmt = lab10.Text
total = soda1 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 300ml" & "Soda " & total)
ElseIf chkSoda.Checked = True And chk500ml.Checked = True Then
orderAmt = lab10.Text
total = soda2 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 500ml" & "Soda " & total)
ElseIf chkSoda.Checked = True And chk1l.Checked = True Then
orderAmt = lab10.Text
total = soda3 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 1l" & "Soda " & total)
ElseIf chkSoda.Checked = True And chk2l.Checked = True Then
orderAmt = lab10.Text
total = soda4 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 2l" & "Soda " & total)
ElseIf chkJuice.Checked = True And chk300ml.Checked = True Then
orderAmt = lab11.Text
total = juice1 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 300ml" & "juice " & total)
ElseIf chkJuice.Checked = True And chk500ml.Checked = True Then
orderAmt = lab11.Text
total = juice2 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 500ml" & "juice " & total)
ElseIf chkJuice.Checked = True And chk1l.Checked = True Then
orderAmt = lab11.Text
total = juice3 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 1l" & "juice " & total)
ElseIf chkJuice.Checked = True And chk2l.Checked = True Then
orderAmt = lab11.Text
total = juice4 * orderAmt
lstReceipt.Items.Add(orderAmt & " Bottles of 2l" & "juice " & total)
End If
End Sub
실제로 그것은 첫 번째 옵션 이었지만 두 개 이상의 항목이 선택되어 있고 작동하지 않았는지 확인해야하므로 피할 수있었습니다. 그런데 당신이 나에게 내 사용법에 무엇이 잘못되었는지 말해 주시겠습니까? –
하지만 둘 다 왜 작동하지 않는지 알아 냈습니다. 이것은 실제로 언급 한 것처럼 다른 방법입니다. 감사합니다. –