Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

Alarm for last sunday of month

$
0
0
Hi all

I have 12 hard drives drives D-O i want to be able to format the next month drive in advance so the last sunday of the current month it will format the aprils drive at 11:00am and so on for each last sunday for all months. this code below that i want to add to, what i want is to add daAlarm5 to do this. Sorry for not making it clear. hope this helps now.

Code:

Private Sub Form_Load()
Dim textfile As String

' Start Timer1 for the Clock And Alarms
    Timer1.Interval = 1000
    Timer1.Enabled = True
    Timer10.Interval = 1000
    Timer10.Enabled = True
    Dim daNow As Date
    daNow = Now
'
' Set the Alarm Times
' This example will trigger the alarms after 15, 30 and 45 seconds
' after starting the Program
' To set an alarm for a specific time of day:
' use, daAlarm1 = TimeValue("14:00:00") which will trigger alarm 1 at 14:00
'
    daAlarm1 = Date + TimeValue("06:27:00") ' Alarm set for 06:27
    If Now > daAlarm1 Then daAlarm1 = DateAdd("d", 1, daAlarm1)
    daAlarm2 = Date + TimeValue("14:27:00") ' Alarm set for 14:27
    If Now > daAlarm2 Then daAlarm2 = DateAdd("d", 1, daAlarm2)
    daAlarm3 = Date + TimeValue("22:27:00") ' Alarm set for 22:27
    If Now > daAlarm3 Then daAlarm3 = DateAdd("d", 1, daAlarm3)
    daAlarm4 = Date + TimeValue("18:27:00") ' Alarm set for 18:27 Sundays Only
    If Now > daAlarm4 Then daAlarm4 = DateAdd("d", 1, daAlarm4)
    Timer1.Interval = 1000
    Timer1.Enabled = True

' Get Folder names from dirnames.txt file and import them to form FolderCreator\Combo1
    Open "C:\users\administrator\dirnames.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, textfile
    FolderCreator.Combo1.AddItem (textfile)
    Loop
    Close #1


' Fire Rx Event Every Two Bytes
    MSComm1.RThreshold = 1

' When Inputting Data, Input 2 Bytes at a time
    MSComm1.InputLen = 13

' 9600 Baud, No Parity, 8 Data Bits, 1 Stop Bit
    MSComm1.Settings = "9600,N,8,1"
' Disable DTR
    MSComm1.DTREnable = False

' Open COM1
    MSComm1.CommPort = 1  ' Set Com Port to 1
    MSComm1.PortOpen = True  ' Turn on Com Port
  '  MSComm1.InBufferCount = 0 ' Clear Buffers
    MSComm1.InputLen = 0
End Sub



Private Sub Timer1_Timer()
    DispTime = Now  ' Show Date on main screen.
' Create CSV file with details from NOK,lst(17) and Labels 1 - 16 at time 06:30
    If Now >= daAlarm1 Then
    Open "C:\users\administrator\my documents\counts.csv" For Append As #1
' For I = 0 To Lis't1.ListCount - 1
    Print #1, Now & ",22:30-06:30," & POK.Caption & "," & NOK.Caption & "," & Label1.Caption & "," & Label2.Caption & "," & Label3.Caption & "," & Label4.Caption & "," & Label5.Caption & "," & Label6.Caption & "," & Label7.Caption & "," & Label8.Caption & "," & Label9.Caption & "," & Label10.Caption & "," & Label11.Caption & "," & Label12.Caption & "," & Label13.Caption & "," & Label14.Caption & "," & Label15.Caption & "," & Label16.Caption
' Next
    Close #1
' Clear Labels
    Label1 = ""
    Label2 = ""
    Label3 = ""
    Label4 = ""
    Label5 = ""
    Label6 = ""
    Label7 = ""
    Label8 = ""
    Label9 = ""
    Label10 = ""
    Label11 = ""
    Label12 = ""
    Label13 = ""
    Label14 = ""
    Label15 = ""
    Label16 = ""
    NOK = ""
    POK = ""
    lst(17).Clear
    lst(0).Clear
    lst(1).Clear
    lst(2).Clear
    lst(3).Clear
    lst(4).Clear
    lst(5).Clear
    lst(6).Clear
    lst(7).Clear
    lst(8).Clear
    lst(9).Clear
    lst(10).Clear
    lst(11).Clear
    lst(12).Clear
    lst(13).Clear
    lst(14).Clear
    lst(15).Clear
    lst(16).Clear
  '    MsgBox "ALARM 1"
    daAlarm1 = DateAdd("d", 1, daAlarm1)
    End If
   
' Create CSV file with details from NOK,lst(17) and Labels 1 - 16 at time 14:30
    If Now >= daAlarm2 Then
    Open "C:\users\administrator\my documents\counts.csv" For Append As #1
' For I = 0 To Lis't1.ListCount - 1
      Print #1, Now & ",6:30-14:30," & POK.Caption & "," & NOK.Caption & "," & Label1.Caption & "," & Label2.Caption & "," & Label3.Caption & "," & Label4.Caption & "," & Label5.Caption & "," & Label6.Caption & "," & Label7.Caption & "," & Label8.Caption & "," & Label9.Caption & "," & Label10.Caption & "," & Label11.Caption & "," & Label12.Caption & "," & Label13.Caption & "," & Label14.Caption & "," & Label15.Caption & "," & Label16.Caption
' Next
    Close #1
' Clear Labels
    Label1 = ""
    Label2 = ""
    Label3 = ""
    Label4 = ""
    Label5 = ""
    Label6 = ""
    Label7 = ""
    Label8 = ""
    Label9 = ""
    Label10 = ""
    Label11 = ""
    Label12 = ""
    Label13 = ""
    Label14 = ""
    Label15 = ""
    Label16 = ""
    NOK = ""
    POK = ""
    lst(17).Clear
    lst(0).Clear
    lst(1).Clear
    lst(2).Clear
    lst(3).Clear
    lst(4).Clear
    lst(5).Clear
    lst(6).Clear
    lst(7).Clear
    lst(8).Clear
    lst(9).Clear
    lst(10).Clear
    lst(11).Clear
    lst(12).Clear
    lst(13).Clear
    lst(14).Clear
    lst(15).Clear
    lst(16).Clear
    '    MsgBox "ALARM 2"
    daAlarm2 = DateAdd("d", 1, daAlarm2)
    End If
   
' Create CSV file with details from NOK,lst(17) and Labels 1 - 16 at time 22:30
    If Now >= daAlarm3 Then
    Open "C:\users\administrator\my documents\counts.csv" For Append As #1
' For I = 0 To Lis't1.ListCount - 1
      Print #1, Now & ",14:30-22:30," & POK.Caption & "," & NOK.Caption & "," & Label1.Caption & "," & Label2.Caption & "," & Label3.Caption & "," & Label4.Caption & "," & Label5.Caption & "," & Label6.Caption & "," & Label7.Caption & "," & Label8.Caption & "," & Label9.Caption & "," & Label10.Caption & "," & Label11.Caption & "," & Label12.Caption & "," & Label13.Caption & "," & Label14.Caption & "," & Label15.Caption & "," & Label16.Caption
' Next
    Close #1
         
'Clear Labels
    Label1 = ""
    Label2 = ""
    Label3 = ""
    Label4 = ""
    Label5 = ""
    Label6 = ""
    Label7 = ""
    Label8 = ""
    Label9 = ""
    Label10 = ""
    Label11 = ""
    Label12 = ""
    Label13 = ""
    Label14 = ""
    Label15 = ""
    Label16 = ""
    NOK = ""
    POK = ""
    lst(17).Clear
    lst(0).Clear
    lst(1).Clear
    lst(2).Clear
    lst(3).Clear
    lst(4).Clear
    lst(5).Clear
    lst(6).Clear
    lst(7).Clear
    lst(8).Clear
    lst(9).Clear
    lst(10).Clear
    lst(11).Clear
    lst(12).Clear
    lst(13).Clear
    lst(14).Clear
    lst(15).Clear
    lst(16).Clear
 '      MsgBox "ALARM 3"
    daAlarm3 = DateAdd("d", 1, daAlarm3)
    End If
  If Now >= daAlarm4 Then
        If Weekday(Now) = vbSunday Then
      Timer6.Enabled = True
          intCount = 0
        daAlarm4 = DateAdd("d", 7, daAlarm4)
           
        End If
    End If
End Sub


regards

steve

Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>