VB中利用time来定时运行程序怎么代码怎么写?
程序A地址是“C:\1.EXE”,VB中利用time,shell来写一个程序。要求点击command1,2秒后自动运行程序A,4秒后就关闭程序A,6秒后自动运行程序A,8...
程序A地址是“C:\1.EXE”,VB中利用time,shell来写一个程序。要求点击command1 ,2秒后自动运行程序A,4秒后就关闭程序A,6秒后自动运行程序A,8秒后自动关闭该VB编写的程序。
展开
2个回答
2013-11-05
展开全部
Dim p As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
p = 0
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End SubPrivate Sub Timer1_Timer()
p = p + 1
If p = 2 Then
Shell "C:\1.exe", vbNormalFocus
ElseIf p = 4 Then
Shell "cmd.exe /k taskkill /f /im 1.exe &exit", vbHide
ElseIf p = 6 Then
Shell "C:\1.exe", vbNormalFocus
ElseIf p = 8 Then
Shell "cmd.exe /k taskkill /f /im 1.exe &exit", vbHide
End If
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
p = 0
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End SubPrivate Sub Timer1_Timer()
p = p + 1
If p = 2 Then
Shell "C:\1.exe", vbNormalFocus
ElseIf p = 4 Then
Shell "cmd.exe /k taskkill /f /im 1.exe &exit", vbHide
ElseIf p = 6 Then
Shell "C:\1.exe", vbNormalFocus
ElseIf p = 8 Then
Shell "cmd.exe /k taskkill /f /im 1.exe &exit", vbHide
End If
End Sub
2013-11-05
展开全部
他用得是模块级变量,会多耗内存的,应该用局部静态变量。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询