我完全是VB.net的新手,我試圖運行一個半中級腳本來檢查某些正在打開的文件。當它第一次打開時,它檢查一個特定的程序,然後它將繼續檢查一個定時器上的不同程序。當我運行的代碼,小組定時器1從不運行時,我把它設置爲每20秒運行..計時器滴答處理程序沒有運行
Imports System.Net
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If (Process.GetProcessesByName("PROGRAM1").Length >= 1) Then
MessageBox.Show("This Client is already running!", "IG Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Environment.Exit(0)
Else
Process.Start(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "program.exe"))
'''' OPEN PROGRAM ABOVE ''''
End If
For Each frm As Form In Application.OpenForms
frm.WindowState = FormWindowState.Minimized
Next frm
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If (Process.GetProcessesByName("PROGRAM2").Length >= 1) Then 'CHECK FOR PROGRAM
MessageBox.Show("Program is running!", "IG Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Environment.Exit(0)
Form3.Show()
Else
MessageBox.Show("Program is not running!")
End If
End Sub
End Class
以上是代碼,我已經有..我的計時器子要麼不運行或ISN」每20秒檢查一次。 任何想法?
呼叫['Timer.Start()'](http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.start.aspx)第一,或者設置' Timer.Enabled = True' – alldayremix 2013-02-24 22:42:24
需要啓動計時器。你是否啓動/啓用你的計時器?如果是,在哪裏? – Steve 2013-02-24 22:43:00
我還沒有叫它:P我現在叫它,並讓你知道它是否工作(: – 2013-02-24 22:45:22