gpt4 book ai didi

vb.net - VB代码不计算

转载 作者:行者123 更新时间:2023-12-02 10:02:48 25 4
gpt4 key购买 nike

出于某种原因,当我运行它时,它只计算为 0我哪里出错了? :(用户有 3 个输入框来放置值。从那里应该计算这些值。它只等于 0 值。我没有收到任何错误

Option Strict On
Public Class Form1

Private Sub btnCal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCal.Click

Dim dblPacA, dblPacB, dblPacC, dblAnswerA, dblAnswerB, dblAnswerC, dblGrandTotal As Double
Dim dblAnswerA1, dblAnswerB1, dblAnswerC1 As Double

'Packages Retail
Dim dblPACA_FACTOR As Double = 99
Dim dblPACB_FACTOR As Double = 199
Dim dblPACC_FACTOR As Double = 299

'Rate of each range
Dim dblTENNINE_FACTOR As Double = 0.8
Dim dblTWONINE_FACTOR As Double = 0.7
Dim dblFIVENINE_FACTOR As Double = 0.6
Dim dblONETEN_FACTOR As Double = 0.5

Try
'important calculate
dblAnswerA1 = dblPacA * dblPACA_FACTOR
dblAnswerB1 = dblPacB * dblPACB_FACTOR
dblAnswerC1 = dblPacC * dblPACC_FACTOR



dblPacA = CDbl(txtPacA.Text)
dblPacB = CDbl(txtPacB.Text)
dblPacC = CDbl(txtPacC.Text)

dblGrandTotal = dblAnswerA + dblAnswerB + dblAnswerC
lblGrandTotal.Text = "Gran Total:" & (dblGrandTotal.ToString("c"))
'lblAnswer.Text = dblAnswer.ToString
'lblAnswer.Text = "PackageA:" & dblAnswerA _
' & "PackageB:" & dblAnswerB & "PackageC:" _
'& dblAnswerC & "GrandTotal:" & dblGrandTotal
Catch
End Try

If dblPacA >= 0 Then
If dblPacA < 10 Then
dblAnswerA = dblAnswerA1
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
ElseIf dblPacA >= 10 And dblPacA < 20 Then
dblAnswerA = dblAnswerA1 * dblTENNINE_FACTOR
lblAnswerA.Text = "PackageA:" & (dblAnswerA.ToString("c"))
ElseIf dblPacA >= 20 And dblPacA < 50 Then
dblAnswerA = dblAnswerA1 * dblTWONINE_FACTOR
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
ElseIf dblPacA >= 50 And dblPacA < 100 Then
dblAnswerA = dblAnswerA1 * dblFIVENINE_FACTOR
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
ElseIf dblAnswerA >= 100 Then
dblAnswerA = dblAnswerA1 * dblONETEN_FACTOR
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
End If
Else
MessageBox.Show("txtPacA must be greater than or equal to 0", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If

If dblPacB >= 0 Then
If dblPacB >= 10 And dblPacB <= 19 Then
dblAnswerB = dblAnswerB1 * dblTENNINE_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
ElseIf dblPacB >= 20 And dblPacB <= 49 Then
dblAnswerB = dblAnswerB1 * dblTWONINE_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
ElseIf dblPacB >= 50 And dblPacB <= 99 Then
dblAnswerB = dblAnswerB1 * dblFIVENINE_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
Else
dblAnswerB = dblAnswerB * dblONETEN_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
End If
Else
MessageBox.Show("txtPacB must be greater than or equal to 0", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If

If dblPacC >= 0 Then
If dblPacC >= 10 And dblPacC <= 19 Then
dblAnswerC = dblAnswerC1 * dblTENNINE_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
ElseIf dblPacC >= 20 And dblPacA <= 49 Then
dblAnswerC = dblAnswerC1 * dblTWONINE_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
ElseIf dblPacC >= 50 And dblPacC <= 99 Then
dblAnswerC = dblAnswerC1 * dblFIVENINE_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
Else
dblAnswerC = dblAnswerC1 * dblONETEN_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
End If
Else
MessageBox.Show("txtPacC must be greater than or equal to 0", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If

End Sub
End Class

最佳答案

dblAnswerA1 = dblPacA * dblPACA_FACTOR

dblPacA 的值在哪里设置?它不是。其 0

关于vb.net - VB代码不计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8003925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com