我无法让我的消息框出现在正确的实例中(初学者)

时间:2015-03-23 01:32:07

标签: .net vb.net visual-studio-2010

我正在编写一个小应用程序,我无法让我的消息框在正确的时间工作,当它出现时,标签仍然更新。它让我疯了!消息框需要显示日期小于19且大于22.两个底部错误确实正常工作至少我相信他们之前做过(在我尝试让其他错误工作之前)。以下是我的代码。当输入的数字小于19且大于22 btw时,我需要出现上面提到的错误(消息框)。

谢谢:)。这是在vb.net btw。

'Date: 3/21/2015
'Purpose: The application finds the amount of a monthly pau if you are paid on a penny or nickel a day for the first workday then the pay is doubled each workday.
'    Inexpereinced workers are paid a penny a day, experienced workers are paid a nickel. 


Option Explicit On


Public Class frmPennyOrNickelADay

    Const _cdecPenny As Decimal = 0.01D
    Const _cdecNickel As Decimal = 0.05D
    Const _cDecDoubledAmount As Decimal = 2D
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim decSalary As Decimal = 0
        Dim intDay As Integer
        Dim decPenny As Decimal = 0.01D
        Dim decNickel As Decimal = 0.05D
        Dim decDouble As Decimal = 2
        Dim intRunningTally As Integer
        Dim decMaxNumber As Decimal
        If IsNumeric(txtDaysWorkedUserEntry.Text) = True Then
            intDay = Convert.ToInt32(txtDaysWorkedUserEntry.Text)
            If intDay > 0 Then
                If radPenny.Checked = True Then
                    If intDay < 19 Then
                        MessageBox.Show("Error", "input error", MessageBoxButtons.OK)
                        lblAmountEarnedResult.Text = ""

                    End If
                End If
                If radPenny.Checked = True Then
                    decSalary = decPenny

                ElseIf radNickel.Checked = True Then
                    decSalary = decNickel
                End If

                For intDay = 1 To intDay
                    If intDay = 1 Then
                        decSalary = decSalary
                    Else
                        decSalary *= decDouble
                    End If
                    intRunningTally += decSalary

                Next

                lblAmountEarnedResult.Text = decSalary.ToString("C2")
            Else
                MessageBox.Show("Please enter a number greater than one", "Invalid Entry", MessageBoxButtons.OK)


            End If
        Else
            MessageBox.Show("Letters are not an acceptible input within this application, please try again...enter a value greater than one.",
                            "Invalid Data", MessageBoxButtons.OK)
        End If



    End Sub

2 个答案:

答案 0 :(得分:1)

您需要在显示消息框后退出子例程,尝试使用Exit Sub

If intDay < 19 Then
    MessageBox.Show("Error", "input error", MessageBoxButtons.OK)
    lblAmountEarnedResult.Text = ""
    Exit Sub
End If

答案 1 :(得分:0)

更改

If intDay < 19 Then

If (intDay < 19 or intDay >22) then