查看: 51  |  回复: 0
  VB6 Select Case 的范围表示 Case Is
楼主
发表于 2025年6月18日 15:01

新建From1(窗体),新建Command1(按钮CommandButton),代码:

Private Sub Command1_Click()
    Dim bytesTotal&

    bytesTotal = 2

    Select Case bytesTotal
        Case Is = 1
            Debug.Print "=1"
            GoTo hOut
            
        Case Is <> 2 '不会运行
            Debug.Print "<>2"
            GoTo hOut
            
        Case Is <= 20
            Debug.Print "<=20"
            GoTo hOut

        Case Is > 100
            Debug.Print ">100"
            GoTo hOut
    End Select

    Debug.Print "hello"
hOut:
End Sub

运行结果:

<=20

可以运行<,<=,=,>,>=运算符,不能使用<>。

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2025 MaNongKu.com