< Hanging On [Timer Problem] >
Code:
' Problem:
' Before I fire I can access other features
' After I fire and set the form to invisible, I can't access my Start Button
' Something seems to he holding on to things.
' What sort of stupidy have I envoked here?
' Controls Required:
' Command1
' Timer1
' Label1
Option Explicit
Public bStopThis 'get out of loop (Lable Flash)
Public stFile As String 'file to check for content
Public stDir As String 'dir of file
Public sFired As Boolean 'used to stop timer from firing till past the minuite
'get tic count API used in flickering the label caption (Label1)
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Activate()
Dim x 'store get tic count
bStopThis = False
Do
Label1.ForeColor = IIf(Label1.ForeColor = vbWhite, vbRed, vbWhite)
x = GetTickCount + 750 'flash timer for label1
Do Until x < GetTickCount Or Forms.Count = 0 'flash till
DoEvents
Loop
Loop Until bStopThis = True Or Forms.Count = 0 'kill the loop
End Sub
Private Sub Command1_Click()
bStopThis = True 'option to turn off blinking
Form1.Visible = False
End Sub
Private Sub Form_DblClick()
'kill the application
bStopThis = True
Unload Me
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
'stDir = "K:\Working\" 'restore when done testing
stDir = "c:\" 'testing data condition
stFile = Dir$(stDir & "*.*")
'label positioning on screen as well as command button positioning
Label1.Left = (Screen.Width / 2) - (Label1.Width / 2)
Label1.Top = (Screen.Height / 2) - (Label1.Height / 2)
Command1.Left = (Screen.Width / 2) - (Command1.Width / 2)
Command1.Top = Screen.Height - (Command1.Height + 2000)
Me.WindowState = vbMaximized 'full view
End Sub
Private Sub Timer1_Timer()
DoEvents
Dim x 'get formatted current time
x = Format(Now, "HH:NN AM/PM")
Select Case x
'if these times and file is not empty and it has not been fired yet then fire it
Case "10:10 AM", "10:14 AM", "10:17 AM", "10:20 AM" 'test
'Case "08:50 AM", "11:50 AM", "01:50 PM", "03:50 PM" 'resore to this when test complete
If stFile <> "" Then 'orders in file
If sFired = False Then
Form1.Label1.Caption = "Orders To Process"
Form1.Visible = True
sFired = True
End If
Else 'nothing in file
If sFired = False Then
Form1.Label1.Caption = "File Empty"
Form1.Visible = True
sFired = True
End If
End If
'at any other time set the firesd condition to false
Case Else
sFired = False
End Select
End Sub