| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2900 人关注过本帖
标题:怎么让程序 5秒钟 自动点击 button按钮
只看楼主 加入收藏
lingandyi
Rank: 1
等 级:新手上路
帖 子:97
专家分:3
注 册:2007-2-25
结帖率:100%
收藏
 问题点数:0 回复次数:17 
怎么让程序 5秒钟 自动点击 button按钮
  高手请给出代码,谢谢了,我做程序老是出错,所以我想这样试试
搜索更多相关主题的帖子: button 按钮 自动 
2007-09-08 08:43
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
这个方法不是点击Button按钮,是调用Button的事件。

放一个Timer控件,Interval=5000,Timer()事件中写Call Command1_Click()


如果你的button不是VB的CommandButton的话……麻烦你问题描述清楚点,把你的思路讲讲
2007-09-08 08:44
lingandyi
Rank: 1
等 级:新手上路
帖 子:97
专家分:3
注 册:2007-2-25
收藏
得分:0 

我在程序里面 不想用timer空件 刷新 ,我想用button 空件 刷新,
想法: 每5秒 程序自动点击下 button ,然后数据刷新

2007-09-08 08:48
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
以下是引用lingandyi在2007-9-8 8:48:35的发言:

我在程序里面 不想用timer空件 刷新 ,我想用button 空件 刷新,
想法: 每5秒 程序自动点击下 button ,然后数据刷新

我想开机,不想按Power键,你教我。

该用就得用,不用Timer你想用啥?

我告诉你,API可以实现定时功能,你愿意用?

2007-09-08 08:50
lingandyi
Rank: 1
等 级:新手上路
帖 子:97
专家分:3
注 册:2007-2-25
收藏
得分:0 
  那到不用,可是我的程序运行一段时间 老师出错    运行时错误  SQL 不存在或者拒绝访问

2007-09-08 08:53
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
以下是引用lingandyi在2007-9-8 8:53:50的发言:
那到不用,可是我的程序运行一段时间 老师出错 运行时错误 SQL 不存在或者拒绝访问

那就仔细排查 为什么SQL会拒绝访问。

Timer又没招你惹你

2007-09-08 08:56
lingandyi
Rank: 1
等 级:新手上路
帖 子:97
专家分:3
注 册:2007-2-25
收藏
得分:0 
... 我看不出来. 我自己看了的 我把代码和数据库打包给你 你帮我 改下好吗? 数据库是SQL2000 的
谢谢你了 ..

2007-09-08 08:57
lingandyi
Rank: 1
等 级:新手上路
帖 子:97
专家分:3
注 册:2007-2-25
收藏
得分:0 
HYqpwE40.rar (343.45 KB) 怎么让程序 5秒钟 自动点击 button按钮



2007-09-08 08:59
multiple19O2
Rank: 1
等 级:新手上路
帖 子:326
专家分:0
注 册:2007-8-29
收藏
得分:0 
不好 我这里没有SQL2000

我这里甚至连VB都没有。

过段时间把编程软件全装上,但最近的确什么都没有。

把具体的代码发上来,更有助于解决问题。
我不是2楼。
2007-09-08 08:59
lingandyi
Rank: 1
等 级:新手上路
帖 子:97
专家分:3
注 册:2007-2-25
收藏
得分:0 

Dim conn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
Dim rs4 As New ADODB.Recordset
Dim rs5 As New ADODB.Recordset
Dim rs6 As New ADODB.Recordset
Dim rs7 As New ADODB.Recordset

'Dim i As Integer
Dim test As Integer
Dim j As Integer
Dim k As Integer
Dim min As Integer
Dim X As Integer
Dim Y As Integer
Dim z As Integer

Private Sub scroll()

Do While True
Dim NewLeft, n As Long
NewLeft = Form1.ScaleWidth
Do While True
LabelMessage.Move NewLeft, 1900
NewLeft = NewLeft - 60
For n = 1 To 20000
DoEvents
Next
'''' 若标签框最末端滚动出窗体视野区域,则重置初始位置

If test = 4 Then
Exit Sub
End If

If NewLeft <= -LabelMessage.Width Then
NewLeft = Form1.ScaleWidth
End If

Loop

Loop


'tuichu:
'MsgBox ("退出程序")


End Sub

Private Sub Command1_Click()
Print "mimaa"


Call Form1.lianjied
Form1.Timer1.Interval = 5000
Call Form1.result
Form1.Show

End Sub

Private Sub Form_Load()
Dim jjjjj As Integer
jjjjj = 200

sj = jjjjj
Label1.BackColor = Form1.BackColor
LabelMessage.BackColor = Form1.BackColor
Label2.BackColor = Form1.BackColor
yi.BackColor = Form1.BackColor
er.BackColor = Form1.BackColor
san.BackColor = Form1.BackColor
class1.BackColor = Form1.BackColor
class2.BackColor = Form1.BackColor
class3.BackColor = Form1.BackColor
Frame1.BackColor = Form1.BackColor
Text1.BackColor = Form1.BackColor
'


Frame2.BackColor = Form1.BackColor
Text2.BackColor = Form1.BackColor

Frame3.BackColor = Form1.BackColor
Text3.BackColor = Form1.BackColor

Frame4.BackColor = Form1.BackColor
Text4.BackColor = Form1.BackColor
'Call connect
'Call result

LabelMessage.AutoSize = True
Label3.AutoSize = True
'Form4.Show

End Sub


Public Sub result()
If (conn.State = 0) Then
Call Form1.lianjied
Form1.Timer1.Interval = 5000
Call Form1.result
Else



Dim i As Integer

Set rs1 = New Recordset
Set rs2 = New Recordset
Set rs3 = New Recordset
Set rs4 = New Recordset


rs4.Open "select count(cPrepay) from tStat where cPrepay=0", conn, adOpenDynamic, adLockOptimistic, -1
rs5.Open "select count(cPrepay) from tStat where cPrepay=0 and sCom like 'a%'", conn, adOpenDynamic, adLockOptimistic, -1
rs6.Open "select count(cPrepay) from tStat where cPrepay=0 and sCom like 'b%'", conn, adOpenDynamic, adLockOptimistic, -1
rs7.Open "select count(cPrepay) from tStat where cPrepay=0 and sCom like 'c%'", conn, adOpenDynamic, adLockOptimistic, -1
rs1.Open "select top 6 sCom from tStat where sCom like 'a%' and cPrepay=0 order by newid()", conn, adOpenDynamic, adLockOptimistic, -1
rs2.Open "select top 6 sCom from tStat where sCom like 'b%' and cPrepay=0 order by newid()", conn, adOpenDynamic, adLockOptimistic, -1
rs3.Open "select top 6 sCom from tStat where sCom like 'c%' and cPrepay=0 order by newid()", conn, adOpenDynamic, adLockOptimistic, -1
class1.Caption = ""
class2.Caption = ""
class3.Caption = ""

Text1.Text = rs4.Fields(0).Value
Text2.Text = rs5.Fields(0).Value
Text3.Text = rs6.Fields(0).Value
Text4.Text = rs7.Fields(0).Value
X = Text2.Text
Y = Text3.Text
z = Text4.Text



If (X < 6) Then
For i = 1 To X
If (rs1.EOF = True Or rs1.BOF = True) Then

Call Form3.lianjied
Form3.Timer1.Interval = 5000
Call Form3.result
Form3.Show

Else
class1.Caption = class1.Caption + " " + rs1.Fields(0).Value
rs1.MoveNext
End If
Next i
Else
For i = 1 To 6
class1.Caption = class1.Caption + " " + rs1.Fields(0).Value
rs1.MoveNext
Next i
End If

If (Y < 6) Then
For j = 1 To Y
If (rs2.EOF = True Or rs2.BOF = True) Then

Call Form3.lianjied
Form3.Timer1.Interval = 5000
Call Form3.result
Form3.Show

Else
class2.Caption = class2.Caption + " " + rs2.Fields(0).Value
rs2.MoveNext
End If
Next j

Else
For j = 1 To 6
class2.Caption = class2.Caption + " " + rs2.Fields(0).Value
rs2.MoveNext
Next j
End If

If (z < 6) Then
For k = 1 To z
If (rs3.EOF = True Or rs3.BOF = True) Then

Call Form3.lianjied
Form3.Timer1.Interval = 5000
Call Form3.result
Form3.Show

Else
class3.Caption = class3.Caption + " " + rs3.Fields(0).Value
rs3.MoveNext
End If
Next k

Else
For k = 1 To 6
class3.Caption = class3.Caption + " " + rs3.Fields(0).Value
rs3.MoveNext
Next k
End If

rs1.Close
rs2.Close
rs3.Close
rs4.Close
rs5.Close
rs6.Close
rs7.Close

End If

End Sub


Private Sub Form_Unload(Cancel As Integer)
test = 4
'conn.Close
End
End Sub

Public Sub lianjied()
If (conn.State = 0) Then
conn.ConnectionString = "SERVER=" & Form2.ip & ";PROVIDER=SQLOLEDB" & _
";DATABASE=" & Form2.ming & ";UID=" & Form2.zhanghao & ";PWD=" & Form2.mima
conn.ConnectionTimeout = 5
conn.Open
End If
End Sub

Private Sub Timer1_Timer()
Call result
End Sub

Private Sub Timer2_Timer()
Form1.LabelMessage.Caption = Form4.Text1.Text
Form1.Label3.Caption = Form4.Text2.Text

End Sub

Private Sub Timer4_Timer()
Call scroll
Timer4.Interval = 0
End Sub



2007-09-08 09:00
快速回复:怎么让程序 5秒钟 自动点击 button按钮
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.061636 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved