选择大小写来检查十进制数的范围 [英] select case to check range of a decimal number

查看:23
本文介绍了选择大小写来检查十进制数的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查 demical 是 0 到 49.99 还是 50 到 99.99 或 100 到 199.99 或大于 200.我正在尝试使用 select case 来执行此操作,但我不确定语法.请帮忙!

i need to check whether a demical is 0 through 49.99 or 50 through 99.99 or 100 through 199.99 or greater than 200. i am trying to do this with select case, but i am not sure of the syntax. please help!

推荐答案

    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

这个(下面)会进入其他情况

this(below) would go into case else

   Dim aa As Double = 1.499

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

this(below) will go into case 1 to 1.49

   Dim aa As Double = 1.4

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

this(below) will go into case 1.5 to 2

   Dim aa As Double = 1.78

其他方法:来自这里

    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

这篇关于选择大小写来检查十进制数的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆