0
학교 프로젝트를하고 있는데 렌탈 장비를 계산할 데이터베이스를 만들어야합니다. 일수를 계산하고 전체 청구서의 합계를 계산하기로되어 있습니다. 내 프로그램이 계산되지 않습니다.내 프로그램이 합계를 계산하지 않습니다
Public Class VandemanForm
' Declare module level variables and constants.
Const FLOOR_POLISHER_PER_DAY_Decimal As Decimal = 25.95D
Const CARPET_STRETCHER_PER_DAY_Decimal As Decimal = 17.95D
Const NAIL_GUN_PER_DAY_Decimal As Decimal = 11.49D
Const AIR_COMPRESSOR_PER_DAY_Decimal As Decimal = 19.95D
'This stores the price per day
Private FloorPolisherPerDayDecimal As Decimal = 0D
Private CarpetStretcherPerDayDecimal As Decimal = 0D
Private NailGunPerDayDecimal As Decimal = 0D
Private AirCompressorPerDayDecimal As Decimal = 0D
'This stores the number of days entered
Private FloorPolisherDaysDecimal As Decimal = 0D
Private CarpetStretcherDaysDecimal As Decimal = 0D
Private NailGunDaysDecimal As Decimal = 0D
Private AirCompressorDaysDecimal As Decimal = 0D
Private Sub CalculateButton_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles CalculateButton.Click
' Declare procedure level variables to hold data
Dim FloorPolisherTotalDecimal As Decimal = 0D
Dim CarpetStretcherTotalDecimal As Decimal = 0D
Dim NailGunTotalDecimal As Decimal = 0D
Dim AirCompressorTotalDecimal As Decimal = 0D
Dim GrandTotalDecimal As Decimal = 0D
' Check to see that data has been entered and in
' the correct format before calculating totals.
If FirstNameTextBox.Text <> vbNullString And _
LastNameTextBox.Text <> vbNullString Then
Else
MessageBox.Show("First name and last name must be entered.", _
"Customer name error.", MessageBoxButtons.OK, _
MessageBoxIcon.Error)
FirstNameTextBox.Focus()
End If
' Check for an entry in the equipment days text boxes and if not
' empty, go on to calculate
Try
If FloorPolisherDaysTextBox.Text <> vbNullString Then
FloorPolisherDaysDecimal = Decimal.Parse(FloorPolisherDaysTextBox.Text)
FloorPolisherTotalDecimal = FloorPolisherDaysDecimal * FloorPolisherPerDayDecimal
End If
If CarpetStretcherDaysTextBox.Text <> vbNullString Then
CarpetStretcherDaysDecimal = Decimal.Parse(CarpetStretcherDaysTextBox.Text)
CarpetStretcherTotalDecimal = CarpetStretcherDaysDecimal * CarpetStretcherPerDayDecimal
End If
If NailGunDaysTextBox.Text <> vbNullString Then
NailGunDaysDecimal = Decimal.Parse(NailGunDaysTextBox.Text)
NailGunTotalDecimal = NailGunDaysDecimal * NailGunPerDayDecimal
End If
If AirCompressorDaysTextBox.Text <> vbNullString Then
AirCompressorDaysDecimal = Decimal.Parse(AirCompressorDaysTextBox.Text)
AirCompressorTotalDecimal = AirCompressorDaysDecimal * AirCompressorPerDayDecimal
End If
GrandTotalDecimal = FloorPolisherTotalDecimal + CarpetStretcherTotalDecimal _
+ NailGunTotalDecimal + AirCompressorTotalDecimal
Catch ex As Exception
MessageBox.Show("The days of the equipment rental must be numeric if entered.",
"Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
' Display the results and format as currency
FloorPolisherSubtotalTextBox.Text = FloorPolisherTotalDecimal.ToString("C")
CarpetStretcherSubtotalTextBox.Text = CarpetStretcherTotalDecimal.ToString("C")
NailGunSubtotalTextBox.Text = NailGunTotalDecimal.ToString("C")
AirCompressorSubtotalTextBox.Text = AirCompressorTotalDecimal.ToString("C")
GrandTotalDecimal = FloorPolisherTotalDecimal + CarpetStretcherTotalDecimal _
+ NailGunTotalDecimal + AirCompressorTotalDecimal
TotalTextBox.Text = GrandTotalDecimal.ToString("C")
End Sub
Private Sub ExitButton_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles ExitButton.Click
Me.Close()
End Sub
Private Sub ClearButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ClearButton.Click
' Clear all text boxes, Return the focus to the first name field.
FirstNameTextBox.Clear()
LastNameTextBox.Clear()
FloorPolisherDaysTextBox.Clear()
CarpetStretcherDaysTextBox.Clear()
NailGunDaysTextBox.Clear()
AirCompressorDaysTextBox.Clear()
FloorPolisherSubtotalTextBox.Clear()
CarpetStretcherSubtotalTextBox.Clear()
NailGunSubtotalTextBox.Clear()
AirCompressorSubtotalTextBox.Clear()
TotalTextBox.Clear()
'Return focus to the first name textbox
FirstNameTextBox.Focus()
End Sub
Private Sub OrderGroupBox_Enter(sender As System.Object, e As System.EventArgs) Handles FloorToolOrderGroupBox.Enter
End Sub
End Class
"내 프로그램이 계산되지 않습니다." 문제를 좁히는 데별로 도움이되지 않습니다. 정확히 무엇이 잘못되었는지 명확히 설명하십시오. 문제가 총합이 0이라면, 당신의'* PerDay' 변수가 0 인 것과 관련이 있다고 생각됩니다. 실제 값을 가진'Const's를 가지고 있지만, 그들은 어디에도 사용 된 것처럼 보이지 않습니다. – Mark
마크, 나는 이것에 초보적이다. 사실, 장비의 각 부분이 소계 또는 총계를 계산하지 않는 이유에 대한 단서가 없습니다. 나는 하루 하루를 바꿨지 만 여전히 효과가 없습니다. – Elsa
은 중단 점을 설정하고 각 줄을 실행하는 것을 감시합니다. 코드를 실행하는 방법에 대해 많은 것을 배울 수 있습니다. 문제를 매우 빠르게 발견하고 계산에서 분리 된 데이터 유효성 검사를 원합니다. – Plutonix