限制多个文本框中允许的值范围

时间:2017-02-17 11:04:39

标签: vb.net

对于我目前的作业,我被要求创建一个表单,允许客户在文本框中输入所需数量的鞋子,然后在第二个文本框中总计成本。但是,顾客不能购买任何一件特定鞋子中的3件以上。我尝试在下面的代码中执行前两个鞋,但是在我添加第二个模型的代码后,我遇到了问题。

    Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click
        Dim qntyClassy, qntyHigh As Double
        txtQntyClassy.Text = qntyClassy
        txtQntyHigh.Text = qntyHigh
        If 0 < Int(txtQntyClassy.Text) And Int(txtQntyClassy.Text) < 4 Then
            txtTotalClassy.Text = FormatCurrency(txtQntyClassy.Text * 43)
            txtQntyClassy.Text = Int(txtQntyClassy.Text)
        Else
            MsgBox("Enter a quantity no greater than 3.")
        End If
        If 0 < Int(txtQntyHigh.Text) And Int(txtQntyHigh.Text) < 4 Then
            txtTotalHigh.Text = FormatCurrency(txtQntyHigh.Text * 48.95)
            txtQntyHigh.Text = Int(txtQntyHigh.Text)
        Else
            MsgBox("Enter a quantity no greater than 3.")
        End If
    End Sub
End Class

0 个答案:

没有答案