如何写“到”在vb.net中 [英] How to write "to" in vb.net
本文介绍了如何写“到”在vb.net中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我如何计算从到到,例如下面的代码。
最高质量1.00至1.83
优质1.84至2.66
平均2.67至3.50
如果lbltotalscore.Text> =1.00和1.83那么
lblscoretable.Text =最高质量
ElseIf lbltotalscore.Text> =1.84和2.66然后
lblscoretable.Text =质量好
ElseIf lbltotalscore.Text> =2.66和 3.50然后
lblscoretable.Text =平均
结束如果
感谢和问候
解决方案
使用功能:
< span class =code-keyword>函数 GetQuality(qValue As Double )作为 字符串
< span class =code-keyword> Dim sValue As String = 质量差
选择 案例 qValue
案例 1 。 0 1 。 83
sValue = 最高质量
案例 1 。 84 2 。 66
sValue = < span class =code-string> 质量好
案例 2 。 67 to 3 。 50
sValue = 平均质量
案例 其他
sValue = 质量差
结束 选择
返回 SValue
结束 功能
注意:此时您正在尝试比较字符串值而不是数字。
另一个没有Select Case的答案
< pre lang =vb> Dim dbl as Double
dbl = CDbl(lbltotalscore.Text)' 将文本转换为Double
如果(db> = 1)和(dbl< ; = 1. 83 )然后 lblscoretable.Text = 最高质量
如果(db> = 1。 84 )和(dbl< = 2。 66 )< span class =code-keyword>然后 lblscoretable.Text = 质量好
如果(db> = 2。 67 )和(dbl <= 3。 50 )然后 lblscoretable.Text = 平均
dear brother,
please help how can I calculate "from" to "to" for example below code.
Highest Quality 1.00 to 1.83
Good Quality 1.84 to 2.66
Average 2.67 to 3.50
If lbltotalscore.Text >= "1.00" And "1.83" Then
lblscoretable.Text = "Highest Quality"
ElseIf lbltotalscore.Text >= "1.84" And "2.66" Then
lblscoretable.Text = "Good Quality"
ElseIf lbltotalscore.Text >= "2.66" And "3.50" Then
lblscoretable.Text = "Average"
End If
Thanks & Regards
解决方案
Use function:
Function GetQuality(qValue As Double) As String Dim sValue As String = "Poor Quality" Select Case qValue Case 1.0 to 1.83 sValue = "Highest Quality" Case 1.84 to 2.66 sValue = "Good Quality" Case 2.67 to 3.50 sValue = "Average Quality" Case Else sValue = "Poor Quality" End Select Return SValue End Function
Note: At this moment you're trying to compare string values instead numeric.
And another answer without "Select Case"
Dim dbl as Double dbl=CDbl(lbltotalscore.Text) 'Converting text to Double If (db>=1) and (dbl<=1.83) then lblscoretable.Text = "Highest Quality" If (db>=1.84) and (dbl<=2.66) then lblscoretable.Text = "Good Quality" If (db>=2.67) and (dbl<=3.50) then lblscoretable.Text = "Average"
这篇关于如何写“到”在vb.net中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文