加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

vb.net – 选择案例来检查十进制数的范围

发布时间:2020-12-17 00:05:35 所属栏目:大数据 来源:网络整理
导读:我需要检查demical是0到49.99或50到99.99或100到199.99还是大于200.我试图用select case来做这个,但我不确定语法.请帮忙! Select Case aa Case 1 To 1.49 MsgBox(1) Case 1.5 To 2 MsgBox(2) Case Else MsgBox("was lower than 1 or higher than 2 or betwe
我需要检查demical是0到49.99或50到99.99或100到199.99还是大于200.我试图用select case来做这个,但我不确定语法.请帮忙!
Select Case aa
        Case 1 To 1.49
            MsgBox(1)
        Case 1.5 To 2
            MsgBox(2)
        Case Else
            MsgBox("was lower than 1 or higher than 2 or between 1.49 and 1.5")
    End Select

这(下面)将进入其他情况

Dim aa As Double = 1.499

这(下面)将进入案例1至1.49

Dim aa As Double = 1.4

这(下面)将进入案例1.5至2

Dim aa As Double = 1.78

其他方式:From here

Select Case value
        Case Is <= 49.99
            Debug.WriteLine("first group")
        Case Is <= 99.99
            Debug.WriteLine("second group")
        Case Is <= 199.99
            Debug.WriteLine("third group")
        Case Else
            Debug.WriteLine("fourth group")
    End Select

也许这也是:

Select Case true
        Case (value >= 0 andalso value <= 49.99)
            Debug.WriteLine("first group")
        Case (value >= 50 andalso value <= 99.99)
            Debug.WriteLine("second group")
        Case (value >= 100 andalso value <= 199.99)
            Debug.WriteLine("third group")
        Case Else
            Debug.WriteLine("fourth group")
    End Select

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读