本人设计拉一个简单动画显示的例子(其中有image1,image2,image3,image4四个图像框控件,我事先在image1,image2,image3中载入图片,然后通过一个定时器将image1,image2,image3中的图片轮流传递给image4)定时器程序如下:
private sub timer1_timer()
  if (flag-3)=0 then
    flag=0
  else
    if flag=0 then
      image4.picture=image1.picture
    elseif flag=1 then
      image4.picture=image2.picture
    elseif flag=2 then
      image4.picture=image3.picture
    end if 
  flag=flag+1
end if
end sub
这里的flag变量定义为窗体级变量,用来控制三副图片的显示顺序,三次一个循环。
可是当我运行的时候,却始终只能将image1.picture载入image4.picture,不知道是为什么,还请各位指点指点。

解决方案 »

  1.   

    单步跟踪下就知道了另看看你的flag值是不是在外面被修改了
      

  2.   

    private sub timer1_timer()
     Static flag As Interger
      if (flag-3)=0 then
        flag=0
      else
        if flag=0 then
          image4.picture=image1.picture
        elseif flag=1 then
          image4.picture=image2.picture
        elseif flag=2 then
          image4.picture=image3.picture
        end if 
      flag=flag+1
    end if
    end sub
      

  3.   

    恩,的确是变量的值发生拉变化!!!!近2天登入不了论坛,现在才结贴,sorry拉 !