Hallo,
ich habe ein Problem, in folgenden Code Segment wird mir ein Fehler gezeigt (siehe Bild).
Ich verstehe nicht, warum der Fehler in diesem Segment abgezeigt wird und in dem anderen nicht?
Nebenbei: Wäre es sinnvoller, generell eine andere Konvertierung der Zahlen anzuwenden?
Freue mich über Feedback
Spoiler anzeigen
Nun habe den Code in ähnlicher Ausführung auch ohne Fehlermeldung...
Spoiler anzeigen
ich habe ein Problem, in folgenden Code Segment wird mir ein Fehler gezeigt (siehe Bild).
Ich verstehe nicht, warum der Fehler in diesem Segment abgezeigt wird und in dem anderen nicht?
Nebenbei: Wäre es sinnvoller, generell eine andere Konvertierung der Zahlen anzuwenden?
Freue mich über Feedback
VB.NET-Quellcode
- Private Sub b_calcp_Click(sender As Object, e As EventArgs) Handles b_calcp.Click
- Try
- 'deklaration
- Dim netA As Double = CDbl(tb_nettopA.Text), netB As Double = CDbl(tb_nettopB.Text)
- Dim count As Double = CDbl(nud_countp.Text)
- Dim mwstpA As Double = CDbl(cb_mwstpA.Text), mwstpB As Double = CDbl(cb_mwstpB.Text)
- 'ea stück
- Dim eatpA As Double = Math.Round(CDbl((netA * mwstpA) / 10), 2), eatpB As Double = Math.Round(CDbl((netB * mwstpB) / 10), 2)
- 'steuer und summe ohne ea
- tb_pA1.Text = Math.Round(CDbl(netA * count * (mwstpA - 1)), 2)
- tb_pA2.Text = Math.Round(CDbl(netA * count + tb_pA1.Text), 2)
- tb_pB1.Text = Math.Round(CDbl(netB * count * (mwstpB - 1)), 2)
- tb_pB2.Text = Math.Round(CDbl(netB * count + tb_pB1.Text), 2)
- 'befreit
- If cb_befreitp.Checked = True Then
- tb_eapA.Text = 0
- tb_eapB.Text = 0
- cb_asonep.Enabled = False
- cb_asonep.Checked = False
- ElseIf cb_befreitp.Checked = False Then
- cb_asonep.Enabled = True
- 'ea gesamt
- If eatpA < 10 And eatpA > 5 Then tb_eapA.Text = Math.Round(CDbl(eatpA * count), 2)
- If eatpA < 5 Then tb_eapA.Text = Math.Round(CDbl(5 * count), 2)
- If eatpA > 10 Then tb_eapA.Text = Math.Round(CDbl(10 * count), 2)
- If eatpB < 10 And eatpB > 5 Then tb_eapB.Text = Math.Round(CDbl(eatpB * count), 2)
- If eatpB < 5 Then tb_eapB.Text = Math.Round(CDbl(5 * count), 2)
- If eatpB > 10 Then tb_eapB.Text = Math.Round(CDbl(10 * count), 2)
- 'count as one
- If cb_asonep.Checked = True Then
- tb_eapA.Text = Math.Round(CDbl(tb_eapA.Text / 2))
- tb_eapB.Text = Math.Round(CDbl(tb_eapB.Text / 2))
- End If
- End If
- 'summe mit ea
- tb_sumpA.Text = Math.Round(CDbl(tb_pA2.Text - tb_eapA.Text), 2)
- tb_sumpB.Text = Math.Round(CDbl(tb_pB2.Text - tb_eapB.Text), 2)
- 'differenz
- If tb_sumpA.Text > tb_sumpB.Text Then tb_diffp.Text = Math.Round(CDbl(tb_sumpA.Text - tb_sumpB.Text), 2)
- If tb_sumpA.Text < tb_sumpB.Text Then tb_diffp.Text = Math.Round(CDbl(tb_sumpB.Text - tb_sumpA.Text), 2)
- Catch ex As Exception
- MessageBox.Show(ex.ToString)
- End Try
- End Sub
Nun habe den Code in ähnlicher Ausführung auch ohne Fehlermeldung...
VB.NET-Quellcode
- Private Sub b_calc_Click(sender As Object, e As EventArgs) Handles b_calc.Click
- Try
- 'deklaration
- Dim net As Double = CDbl(tb_netto.Text), count As Double = CDbl(nud_count.Text)
- Dim mwstA As Double = CDbl(0.07), mwstB As Double = CDbl(0.19)
- 'ea stück
- Dim eat7 As Double = Math.Round(CDbl((net * (mwstA + 1)) / 10), 2), eat19 As Double = Math.Round(CDbl((net * (mwstB + 1)) / 10), 2)
- 'steuer und summe ohne ea
- tb_7a.Text = Math.Round(CDbl(net * count * mwstA), 2)
- tb_7b.Text = Math.Round(CDbl(net * count + tb_7a.Text), 2)
- tb_19a.Text = Math.Round(CDbl(net * count * mwstB), 2)
- tb_19b.Text = Math.Round(CDbl(net * count + tb_19a.Text), 2)
- 'befreit
- If cb_befreit.Checked = True Then
- tb_ea7.Text = 0
- tb_ea19.Text = 0
- cb_asone.Enabled = False
- cb_asone.Checked = False
- ElseIf cb_befreit.Checked = False Then
- cb_asone.Enabled = True
- 'ea gesamt
- If eat7 < 10 And eat7 > 5 Then tb_ea7.Text = Math.Round(CDbl(eat7 * count), 2)
- If eat7 < 5 Then tb_ea7.Text = Math.Round(CDbl(5 * count), 2)
- If eat7 > 10 Then tb_ea7.Text = Math.Round(CDbl(10 * count), 2)
- If eat19 < 10 And eat19 > 5 Then tb_ea19.Text = Math.Round(CDbl(eat19 * count), 2)
- If eat19 < 5 Then tb_ea19.Text = Math.Round(CDbl(5 * count), 2)
- If eat19 > 10 Then tb_ea19.Text = Math.Round(CDbl(10 * count), 2)
- 'count as one
- If cb_asone.Checked = True Then
- tb_ea7.Text = Math.Round(CDbl(tb_ea7.Text / 2))
- tb_ea19.Text = Math.Round(CDbl(tb_ea19.Text / 2))
- End If
- End If
- 'summe mit ea
- tb_sum7.Text = Math.Round(CDbl(tb_7b.Text - tb_ea7.Text), 2)
- tb_sum19.Text = Math.Round(CDbl(tb_19b.Text - tb_ea19.Text), 2)
- 'differenz
- tb_diff.Text = Math.Round(CDbl(tb_sum19.Text - tb_sum7.Text), 2)
- Catch ex As Exception
- MessageBox.Show(ex.ToString)
- End Try
- End Sub