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

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

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

2007-09-08 08:53
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
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.033934 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved