Dim ProcessName As Process() = Process.GetProcessesByName("notepad") 'ตัวอย่างโปรเซส
If ProcessName.Length = 0 Then 'รอโปรเซส
If Label1.Text = "W a i t i n g" Then
Label1.Text = "W a i t i n g ."
Label1.ForeColor = Color.Red
ElseIf Label1.Text = "W a i t i n g ." Then
Label1.Text = "W a i t i n g . ."
Label1.ForeColor = Color.Red
ElseIf Label1.Text = "W a i t i n g . ." Then
Label1.Text = "W a i t i n g . . ."
Label1.ForeColor = Color.Red
Else
Label1.Text = "W a i t i n g"
Label1.ForeColor = Color.Red
End If
ElseIf ProcessName.Length = 1 Then 'โปรเซสทำงาน
If Label1.Text = "S u c c e s s" Then
Label1.Text = "S u c c e s s ."
Label1.ForeColor = Color.Lime
ElseIf Label1.Text = "S u c c e s s ." Then
Label1.Text = "S u c c e s s . ."
Label1.ForeColor = Color.Lime
ElseIf Label1.Text = "S u c c e s s . ." Then
Label1.Text = "S u c c e s s . . ."
Label1.ForeColor = Color.Lime
Else
Label1.Text = "S u c c e s s"
Label1.ForeColor = Color.Lime
End If
Else 'จบการทำงาน
Me.Close()
End If