3

我正在尝试编写一些代码,如果textbox1在 10 之间等于 0,则 HandDecimal = 1。否则,如果textbox1等于 10.1 到 100,则 HandDecimal = 3。否则,如果textbox1等于 100.1 且大于 HandDecimal = 5。

这是我的代码,但它似乎对我不起作用。

        If WeightDecimal = 0 <= 10 Then

            HandDecimal = 1

        ElseIf WeightTextBox.Text = 10 <= 100 Then

            HandDecimal = 3

        ElseIf WeightTextBox.Text >= 100.1 Then

            HandDecimal = 5

        End If

我如何必须更改代码才能使其工作?

4

2 回答 2

7
   Dim weight as Decimal = Decimal.Parse(WeightTextBox.Text) 
   If weight  >= 0 AndAlso weight <= 10 Then

        HandDecimal = 1

    ElseIf weight  > 10 AndAlso weight <= 100 Then

        HandDecimal = 3

    ElseIf weight > 100 Then

        HandDecimal = 5

    End If
于 2012-11-30T03:28:02.170 回答
4

Select CaseTo带运算符的语句

Select Case WeightDecimal
Case 0 To 10
    HandDecimal = 1
Case 10.1 To 100
    HandDecimal = 3
Case Else 
    HandDecimal = 5
End Select
于 2012-11-30T03:54:22.937 回答