记得C有a/2=0的话就证明这个数是2的倍数
VB怎么实现呢?

解决方案 »

  1.   

    If a Mod 2 = 0 Then
        Debug.Print "a是2的倍数"
    End If
      

  2.   

    另一种方法:
    if int(a/2)=a/2 then
        debug.print "a是2的倍数."
    end if
      

  3.   


      
    if n then   '保证n非0
    '最低位不能为1
    if n and &h1   then
             debug.print "n不是2的倍数!"
    else
    debug.print "n是2的倍数!"
    end if
    else
    debug.print "n为零!"
    end if   
     
      

  4.   

    应该是3楼用and高效... 
    if not (n and 1) then ....
      

  5.   

    dim n as integer
    n = 4
    if (n mod 2) = 0 then
        ' ...
    else
        ' ...
    end if
      

  6.   

    使用Mod函数,如果得到的结果是0,那么他就是2的倍数。Mod 运算符
          用来对两个数作除法并且只返回余数。语法result = number1 Mod number2Mod 的语法具有以下几个部分:部分 描述 
    result 必需的;任何数值变量。 
    number1 必需的;任何数值表达式。 
    number2 必需的;任何数值表达式。 
    说明在进行 Mod 运算或求余数运算时,该运算符将 number1 用 number2 除(将浮点数字四舍五入成整数),并把余数作为 result 的值返回。例如,在下列表达式中,A (result) 等于 5。A = 19 Mod 6.7一般说来,不管 result 是否为一个整数,result 的数据类型为 Byte,Byte 变体、Integer、Integer 变体、Long 或一个包含 Long 的 Variant。任何小数部分都被删除。但是,如果任何一个 Null,类型的表达式出现时,result 都将是 Null。任何 Empty 类型表达式都作为 0 处理。