您的位置:程序门 -> vb -> vba



 菜鸟向大虾求教,关于for         next与if       end   if的嵌套用法 


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


菜鸟向大虾求教,关于for next与if end if的嵌套用法
发表于:2008-01-10 13:37:20 楼主
问题:                   在11--99这些数字中,如何用表达式表示所有十位不是大数个位不是奇数的数字?
发表于:2008-01-10 14:14:161楼 得分:0
dim   i   as   integer

for   i   =   11   to   49
        if   i   mod   2   =   0   then   debug.print   i
next   i
发表于:2008-01-10 14:19:032楼 得分:0
十位不是大数是什麼意思?
dim   i   as   integer

for   i=11   to   99
      if   (i   /   10)   /   2   =   0   then     ‘十位是偶数
              if   (i   mod   10)/2   =0   then'不是奇数的数字
                    print   i
            endif
      endif

next
发表于:2008-01-10 16:03:413楼 得分:0
十位不是偶数个位不是奇数
1.
for   i=1   to   9   step   2
        for   j=0   to   8   step   2
                print   i   *   10   +   j
        next   j
next   i

2.
        for   i   =   12   to   98   step   2
                if   i   \   10   mod   2   then   debug.print   i
        next   i

3.
        for   i   =   11   to   99
                if   i   \   10   mod   2   and   not   i   mod   2   then   debug.print   i
        next   i
发表于:2008-01-10 16:49:244楼 得分:0
1   楼   正解
发表于:2008-01-10 17:39:555楼 得分:0
  i   > =   11   and   i   <=   99   and   i   \   10   mod   2   and   not   i   mod   2
发表于:2008-01-10 19:34:226楼 得分:0
谢了
发表于:2008-01-11 19:55:117楼 得分:0
我没用过vba,能把完整的答案告诉我吗?从开头第一行到结尾,谢谢
发表于:2008-01-11 20:04:058楼 得分:0
dim       i       as       integer  

for       i       =       11       to       49  
                if       i       mod       2       =       0     and   i\10   mod   2=1   then       debug.print       i  
next       i


快速检索

最新资讯
热门点击