こんにちは誰か助けてください。私は、ユーザーが選択したアイテムの価格を計算するためのビジュアルな基本機能を書いています。私はif if elseループを使用しましたが、最初の部分だけが出力を表示します。 最初のチェックボックスが選択され、注文ボタンがクリックされた場合、領収書には価格と選択された項目が入力されますが、これは2番目、3番目...チェックボックスでは発生しません。何が間違っていますか?誰かがここに が機能ビジュアルベーシックelse else iff does not working
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
実際、それは私の最初の選択でしたが、複数の項目が選択されていてもうまく機能しなかったかどうかを確認する必要があるので、私はそれを避けました。ところで、私の使い方が間違っているかどうかを教えてもらえますか? –
しかし、私は彼らがなぜうまくいかなかったのかを知りました。これは実際にあなたが言及したように、それを行う別の方法です、ありがとう –