vb.net 视觉基础等于或大于
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13638541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
visual basics equal to or greater than
提问by William Duron
I am trying to write some code that says if textbox1is equal to 0 between 10 then HandDecimal = 1. Else if textbox1is equal to 10.1 through 100, then HandDecimal = 3. Else if textbox1is equal to 100.1 and greater than HandDecimal = 5.
我正在尝试编写一些代码,说明如果textbox1在 10 之间等于 0,则 HandDecimal = 1。否则,如果textbox1等于 10.1 到 100,则 HandDecimal = 3。否则,如果textbox1等于 100.1 且大于 HandDecimal = 5。
Here is my code, but it does not seem to work for me.
这是我的代码,但它似乎对我不起作用。
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
How do I have to change the code to make it work?
我必须如何更改代码才能使其正常工作?
回答by armen.shimoon
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
回答by Mudassir Hasan
Select Casestatement with Tooperator
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

