我正在尝试编写一些代码,说明如果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
如何更改代码才能使其正常工作?
答案 0 :(得分: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
答案 1 :(得分:4)
Select Case
运算符的 To
语句
Select Case WeightDecimal
Case 0 To 10
HandDecimal = 1
Case 10.1 To 100
HandDecimal = 3
Case Else
HandDecimal = 5
End Select