zoukankan      html  css  js  c++  java
  • VBA比较运算符

    VBA支持的比较运算符如下所示。

    假设变量A=10,变量B=20,则 -

    运算符描述示例
    = 检查两个操作数的值是否相等。如果是,那么条件是真。 (A = B)结果为:False
    <> 检查两个操作数的值是否不相等。如果值不相等,则条件为真。 (A <> B)结果为:True
    > 检查左操作数的值是否大于右操作数的值。如果是,那么条件是真。 (A > B)结果为:False
    < 检查左操作数的值是否小于右操作数的值。如果是,那么条件是真。 (A < B)结果为:True
    >= 检查左操作数的值是否大于或等于右操作数的值。 如果是,那么条件是真。 (A >= B)结果为:False
    <= 检查左操作数的值是否小于或等于右操作数的值。如果是,那么条件是真。 (A <= B)结果为:True

    示例

    尝试以下示例以了解VBA中可用的所有比较运算符。

    Private Sub Constant_demo_Click()
       Dim a: a = 10
       Dim b: b = 20
       Dim c
    
       If a = b Then
          MsgBox ("Operator Line 1 : True")
       Else
          MsgBox ("Operator Line 1 : False")
       End If
    
       If a<>b Then
          MsgBox ("Operator Line 2 : True")    
       Else
          MsgBox ("Operator Line 2 : False")    
       End If
    
       If a>b Then
          MsgBox ("Operator Line 3 : True")    
       Else
          MsgBox ("Operator Line 3 : False")    
       End If
    
       If a<b Then
          MsgBox ("Operator Line 4 : True")    
       Else
          MsgBox ("Operator Line 4 : False")    
       End If
    
       If a>=b Then
          MsgBox ("Operator Line 5 : True")    
       Else
          MsgBox ("Operator Line 5 : False")    
       End If
    
       If a<=b Then
          MsgBox ("Operator Line 6 : True")
       Else
          MsgBox ("Operator Line 6 : False")
       End If
    
    End 

    当执行上面的脚本时,会产生类似下面的结果。

    Operator Line 1 : False
    
    Operator Line 2 : True
    
    Operator Line 3 : False
    
    Operator Line 4 : True
    
    Operator Line 5 : False
    
    Operator Line 6 : True
  • 相关阅读:
    mysq foreign外键记录
    查询时隐藏部分身份证号
    SpringBoot接收前端参数
    RabbbitMQ安装
    @configurationProperties注解时 idea弹出 Spring Boot Annotion processor not found in classpath
    rpm,yum和apt使用详解
    python人脸识别
    Fuchsia文章汇总
    Androi O Automotive 介绍
    Linux 版本控制工具之rabbitvcs
  • 原文地址:https://www.cnblogs.com/sunyllove/p/11348080.html
Copyright © 2011-2022 走看看