您的位置:程序门 -> vb -> 基础类



关于timer控件得小问题


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


关于timer控件得小问题[已结贴,结贴人:liwei741852963]
发表于:2007-02-12 11:04:28 楼主
小弟在写一个程序就是,添加一个timer控件,每隔一段时间就循环调用3个程序,例如每5秒自动调用3次ie浏览器,分别打开3个网站,事先声明,我只是打个比方,俺不是写弹窗得流氓软件,我这样写得
private   sub   form_load()
timer1.interval   =   1000
end   sub
private   sub   timer1_timer()
dim   ret&
dim   n   as   integer
dim   url(2)   as   string
url(0)   =   "http://www.baidu.com "
url(1)   =   "http://www.163.com "
url(2)   =   "http://www.sina.com "
for   n=0   to   2
ret&   =   shellEXECute(me.hwnd,   "open ",   url(n),   "   ",   app.path,   1)
next
end   sub
结果一下子跳出来三个呵呵不是间隔得调用得,望高手教我,再次说明,我只是研究,在学习,不是写什么恶意软件,因为我在这里看到问写恶意软件得,被骂惨了,大过年得我不想挨骂
发表于:2007-02-12 11:11:011楼 得分:10
dim   url(2)   as   string
dim   count   as   integer
private   sub   form_load()
timer1.interval   =   1000

url(0)   =   "http://www.baidu.com "
url(1)   =   "http://www.163.com "
url(2)   =   "http://www.sina.com "
count=0
end   sub
private   sub   timer1_timer()
dim   ret&
dim   n   as   integer


ret&   =   shellEXECute(me.hwnd,   "open ",   url(count),   "   ",   app.path,   1)

count=count+1
if   ount> 2   then   count=0
end   sub

   
*****************************************************************************
欢迎使用csdn论坛专用阅读器   :   csdn   reader(附全部源代码)  

最新版本:20070210

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
发表于:2007-02-12 11:20:582楼 得分:0
呵呵,顶楼上,
其实不用timer也可以实现。
发表于:2007-02-12 11:26:023楼 得分:0
编译得时候提示说:在该对象派生得对象模块中成员已经存在,晕,是不是代码有问题
发表于:2007-02-12 11:30:004楼 得分:0
换个变量名
dim   intcount   as   integer
发表于:2007-02-12 11:45:075楼 得分:0
运行完提示说越标
发表于:2007-02-12 11:46:276楼 得分:10
dim   n   as   integer
dim   url(2)   as   string
dim   n   as   integer

private   sub   form_load()
url(0)   =   "http://www.baidu.com "
url(1)   =   "http://www.163.com "
url(2)   =   "http://www.sina.com "
timer1.interval   =   1666
end   sub

private   sub   timer1_timer()

call   shellEXECute(me.hwnd,   "open ",   url(n),   "   ",   app.path,   1)
n   =   n   +   1
if   n   =   3   then   n   =   0

end   sub
发表于:2007-02-12 11:50:047楼 得分:0
of123()   ,你得运行了同样得下标越界
发表于:2007-02-12 12:00:548楼 得分:0
dim   url(2)   as   string
dim   intcount   as   integer
dim   ret&
private   declare   function   shellEXECute   lib   "shell32.dll "   alias   "shellEXECutea "   (byval   hwnd   as   long,   _
  byval   lpoperation   as   string,   byval   lpfile   as   string,   byval   lpparameters   as   string,   byval   lpdirectory   as   string,   _
  byval   nshowcmd   as   long)   as   long
 
private   sub   command1_click()
        ret&   =   shellEXECute(vbnull,   "open ",   "d:\10.txt ",   "   ",   vbnull,   vbnull)
end   sub

private   sub   form_load()
timer1.interval   =   1000

url(0)   =   "http://www.baidu.com "
url(1)   =   "http://www.163.com "
url(2)   =   "http://www.sina.com "
intcount   =   0
end   sub
private   sub   timer1_timer()

dim   n   as   integer


'ret&   =   shellEXECute(me.hwnd,   "open ",   url(intcount),   "   ",   app.path,   1)
ret&   =   shellEXECute(vbnull,   "open ",   url(intcount),   "   ",   vbnull,   vbnull)

intcount   =   intcount   +   1
if   intcount   >   2   then   intcount   =   0
end   sub
发表于:2007-02-12 12:12:389楼 得分:0
还是下标越界^_^
发表于:2007-02-12 12:32:2010楼 得分:0
没问题

你的代码?
发表于:2007-02-12 12:38:2011楼 得分:0
你的初始设置有问题,是基数   1   起始的吧?不允许   url(0)。这样强制声明:

dim   url(0   to   2)   as   string
发表于:2007-02-12 12:40:5212楼 得分:0
"for   n=0   to   2 "   当然是一下子打开三个啦,就像楼上几位所说的,用个计数变量就行了。
dim   intcount   as   integer
iif(intcount   <   2,intcount=intcount+1,intcount=0)
call   shellEXECute(me.hwnd,   "open ",   url(n),   "   ",   app.path,   1)
发表于:2007-02-12 13:14:2813楼 得分:0
晕死,还是下标越界
发表于:2007-02-12 13:27:0714楼 得分:0
是我程序错误,谢谢各位,马上结贴


快速检索

最新资讯
热门点击