如何在发现错误时停止运行代码?

时间:2013-10-13 20:48:44

标签: vb.net

所以我只是在做一个小应用程序,我在这里有一个说

的条款
If hoursPerPeriod > 0 And salary > 0 Then
        If numberPayPeriods = 0 Then
            MessageBox.Show("Please enter number of pay periods!")
        End If
        txtCalculatedPaycheckGross.Text = salary / numberPayPeriods
    End If

因此,如果用户输入他们的薪水信息并填写他们的小时和工资,该计划将只计算他们的薪水。但如果支付期间的数量为0,则在修复之前不会计算任何内容。问题是,在显示消息框要求他们输入值后,如何停止代码继续?

1 个答案:

答案 0 :(得分:3)

If hoursPerPeriod > 0 And salary > 0 Then
        If numberPayPeriods = 0 Then
            MessageBox.Show("Please enter number of pay periods!")
        else
            txtCalculatedPaycheckGross.Text = salary / numberPayPeriods
        end if
    End If
相关问题