Étape 6: Le Code
Cliquez sur Démarrer = > programmes = > accessoires = > cliquez sur bloc-notes
Ou
Cliquez sur Démarrer = > cliquez exécuter = > tapez Notepad dans la zone d’entrée exécuter puis cliquez sur OK.
2) copiez le code ci-dessous l’Apostrophe et les astérisques ligne puis collez-le dans le bloc-notes.
' *********************************************
Dim avis
Dim Message
Dim fso
Dim objFile
Dim arrLines
Dim arrList
Dim FileName
Dim Hol(12)
Set fso = CreateObject("Scripting.FileSystemObject")
FileName = « c:\MySpecialDates.txt »
Const ForReading = 1
Const ForWriting = 2 "sera au fil de l’écriture, tout
Const ForAppending = 8 ' créera ou ajouter fichier
' ce code va créer le fichier de données
Si (fso. FileExists(FileName)) = faux alors
Set objFile = FSO. OpenTextFile (FileName, ForAppending, True)
objFile.Close
Fin si
' Gestion des erreurs
On Error Resume Next
"Inputbox standard
Avis = « Mes Dates spéciales - aujourd'hui est » & WeekDayNAme(WeekDay(Date)) & "" & Date
Message = « Que voulez-vous faire? » & vbcr & vbcr & _
« 1 - affichage des Dates pour ce mois-ci » & vbcr & _
« 2 - Affichage des Dates pour le mois prochain » & vbcr & _
« 3 - Ajouter une Date et un nom à votre liste » & vbCr & _
« 4 - supprimer une Date et le nom de votre liste "& vbcr & vbcr & _
« Entrer le numéro de votre choix. »
« Résultats de InputBox
Question = InputBox(message,Notice)
« Recherchez Null ou vide inputbox puis annule
IF IsEmpty(Question) puis
WScript.quit()
Else If Len(Question) = 0 THEN
WScript.quit()
Question de ELSEIF = 0 THEN
WScript.quit()
D’AUTRE
Sélectionnez une Question affaire
Cas 1 Run(1)
Cas 2 Run(2)
Cas 3 Run(3)
Cas 4 Run(4)
END SELECT
END IF
« — Affaire des déclarations de résultat
Void Run(var)
Set WS = CreateObject("WScript.shell")
« Janvier
"Ceci vérifie si le mois en cours est Dec de décider quelle date de vacances à utiliser
IF Month(date) = « 12 » then
Hol (0) = "01/01 /" & Right(DateSerial(Year(Date)+1,1,1),4) & « Jour de l’an »
Hol(1) = « 0 » & DateSerial(Year(Date)+1,1,22) - Weekday(DateSerial(Year(Date)+1,1,22),3) & « MLK Day »
D’AUTRE
Hol (0) = "01/01 /" & Right(DateSerial(Year(Date),1,1),4) & « Jour de l’an »
Hol(1) = « 0 » & DateSerial(Year(Date),1,22) - Weekday(DateSerial(Year(Date),1,22),3) & « MLK Day »
END IF
« Février
Hol(2) = "02/14 /" & Year(Date) & « Valentin »
Hol(3) = « 0 » & DateSerial(Year(Date),3,1) - Weekday(DateSerial(Year(Date),3,1),3) - 7 & "jour du Président"
' Peut
Hol(4) = « 0 » & DateSerial(Year(Date),6,1) - Weekday(DateSerial(Year(Date),6,1),3) & « Memorial Day »
« Juillet
Hol(5) = "07/04 /" & Year(Date) & « Independence Day »
« Septembre
Hol(6) = « 09/0 » & Mid(DateSerial(Year(Date),9,8) - Weekday(DateSerial(Year(Date),9,8),3),3,1) & « / » & Year(Date) & « Labor Day »
' Octobre
Hol(7) = DateSerial(Year(Date),10,15) - Weekday(DateSerial(Year(Date),10,15),3) & « Columbus Day »
« Novembre
Hol(8) = DateSerial(Year(Date),11,11) & « Veterans' Day »
Hol(9) = DateSerial(Year(Date),11,29) - Weekday(DateSerial(Year(Date),11,29),6) & "Thanksgiving Day"
« Décembre
Hol(10) = DateSerial(Year(Date),12,25) & « Christmas Day »
Hol(11) = DateSerial(Year(Date),12,31) & « Nouvel an »
Sélectionnez la Case var
Cas 1' Découvre le mois en cours
Set objRegEx = CreateObject("VBScript.RegExp")
DateSearch = Right(String(2,"0") & Month(Date), 2)
objRegEx.Pattern = "^" & DateSearch
Set objFile = fso. OpenTextFile (FileName, ForReading)
Set arrLines = CreateObject("System.Collections.ArrayList")
Jusqu'à objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
IF colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
arrLines.Add(strSearchString)
Prochaine
END IF
Boucle
« Filtre, Add & tri vacances pour calendrier mois
Pour i = 0 à 11
Set colMatches = objRegEx.Execute(hol(i))
IF colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
arrLines.Add(hol(i))
arrLines.sort()
Prochaine
END IF
Prochaine
« Écrire des dates spéciales tout à nouveau fichier donc le jour de la semaine peut être ajouté
Dim TempFile
tempfile = « c:\Dates.txt »
Set objFile = FSO. OpenTextFile (TempFile, ForAppending, True)
objFile.Close
« Rejoignez le tableau avec saut de ligne
StrNewFile Dim : strNewFile = Join (arrLines.ToArray, + "\n")
« Ré-ouvrir le fichier pour la lecture
Set objFile = fso. OpenTextFile (TempFile, ForWriting, False)
« Écrire le nouveau texte
objFile.Write strNewFile
objFile.Close
"Tempfile ouverte lire, ajouter les jours de semaine puis supprimer fichier temporaire
Set objFile = fso. OpenTextFile (TempFile, ForReading)
Jusqu'à objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
Si colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
« Nom d’affichage jour de semaine pour vacances ou AnnvYear avec l’année en cours
Si l’année (gauche (strSearchString, InStr (strSearchString,"")-1))=Year(DATE) puis
strSearchString = WeekDayName(WeekDay(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (year(Date))) & ":" & strSearchString
« Nom d’affichage jour de semaine et année comptent
D’autre
strSearchString = WeekDayName(WeekDay(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (year(Date))) & ":" & strSearchString & ":" & DateDiff("y",year(Left(strSearchString,10)),Year(Date)) & « Ans »
END IF
MSG1 = msg1 & strsearchstring & vbcrlf
Prochaine
END IF
Boucle
objFile.Close
' Créer calendrier pour ajouter à la boîte de message Merci lba
m = Month(date)
y = Year(Date)
w = Weekday (DateSerial (y, m, 1), w1) -1
l = jour (DateSerial (y, m + 1, 0)) + w
"Les noms de jour à la première ligne
For i = 1 à 7
o = o & "" & WeekdayName (i, True) & ""
Prochaine
« Date des nombres
o = o & vbCrLf
For i = 1 à l
d = i - w
IF d < 1 puis
o = o & «--»
ELSE IF Len(d) = 1 then
o = o & "" & d & ""
D’AUTRE
o = o & "" & d & ""
END IF
END IF
Si (i-1) Mod 7 = 6 alors
o = o & vbCrLf
End If
Prochaine
« Afficher les résultats
MsgBox Msg1 & vbCrLf & o,,"journées spéciales de" & MonthName(Month(Date)) & "" & Year(Date)
« Supprimer fichier temporaire
FSO. DeleteFile(Tempfile)
Case 2' Voir le mois prochain
Set objRegEx = CreateObject("VBScript.RegExp")
DateSearch = Right(String(2,"0") & Month(DateAdd("M",1,date)), 2)
objRegEx.Pattern = "^" & DateSearch
Set objFile = fso. OpenTextFile (FileName, ForReading)
Set arrLines = CreateObject("System.Collections.ArrayList")
Jusqu'à objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
Si colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
arrLines.Add(strSearchString)
Prochaine
END IF
Boucle
« Filtre, Add & tri vacances pour calendrier mois
Pour i = 0 à 11
Set colMatches = objRegEx.Execute(hol(i))
Si colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
arrLines.Add(hol(i))
arrLines.sort()
Prochaine
Fin si
Prochaine
« Écrire des dates spéciales tout à nouveau fichier donc le jour de la semaine peut être ajouté
Dim TempFile2
tempfile2 = « c:\Dates.txt »
Set objFile = FSO. OpenTextFile (TempFile2, ForAppending, True)
objFile.Close
« Rejoignez le tableau avec saut de ligne
StrNewFile2 Dim : strNewFile2 = Join (arrLines.ToArray, + "\n")
« Ré-ouvrir le fichier pour la lecture
Set objFile = fso. OpenTextFile (TempFile2, ForWriting, False)
« Écrire le nouveau texte
objFile.Write strNewFile2
objFile.Close
"Tempfile ouverte lire, ajouter les jours de semaine puis supprimer fichier temporaire
Set objFile = fso. OpenTextFile (TempFile2, ForReading)
Jusqu'à objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
Si colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
« Nom d’affichage jour de semaine pour les vacances de janvier
Si l’année (gauche (strSearchString, InStr (strSearchString,"")-1))=DateAdd("Y",1,Year(DATE)) puis
strSearchString = WeekDayName(WeekDay(DateAdd("yyyy",1,(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (Year(Date))) & ":" & strSearchString
"Mois en cours est de 12, AnnvMonth 01 affichage jour de semaine et le nombre total d’années pour l’année prochaine
ElseIf Month (Date) = « 12 » et Left(strSearchString,2) = « 01 » et Mid(strSearchString,6,1) = « / » puis
strSearchString = WeekDayName(WeekDay(DateAdd("yyyy",1,(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (Year(Date))) & ":" & strSearchString & ":" & DateDiff("y",year(Left(strSearchString,10)),Year(Date)) + 1 & "Ans"
"Mois en cours est de 12, AnnvMonth est 01 sans nom de jour de semaine correct AnnvYear puis diplay
ElseIf Month (Date) = « 12 » et Left(strSearchString,2) = « 01 » et Mid(strSearchString,6,1) = "" alors
strSearchString = WeekDayName(WeekDay(DateAdd("yyyy",1,(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (Year(Date))) & ":" & strSearchString
' Nom du jour courant affichage Annv date sans année ou les jours fériés
Else if an (gauche (strSearchString, InStr (strSearchString,"")-1))=Year(DATE) puis
strSearchString = WeekDayName(WeekDay(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (year(Date())) & ":" & strSearchString
' Affiche le nom du jour et de calculer les années
D’autre
strSearchString = WeekDayName(WeekDay(mid(strSearchString,1,2) & « / » & Mid(strSearchString,4,2) & « / » & (year(Date())) & ":" & strSearchString & ":" & DateDiff("y",year(Left(strSearchString,10)),Year(Date)) & « Ans »
END IF
MSG1 = msg1 & strsearchstring & vbcrlf
Prochaine
END IF
Boucle
objFile.Close
"Créer le calendrier pour le mois prochain à ajouter à la boîte de message Merci lba
m = Month(DateAdd("M",1,date))
"Si le mois en cours est Dec, veulent afficher le mois prochain et l’année civile
Si Month(date) = « 12 » then
Y =Year(DateAdd("YYYY",1,date))
D’AUTRE
Y = Year(Date)
END IF
w = Weekday (DateSerial (y, m, 1), w1) -1
l = jour (DateSerial (y, m + 1, 0)) + w
"Les noms de jour à la première ligne
For i = 1 à 7
o = o & "" & WeekdayName (i, True) & ""
Prochaine
' Date
o = o & vbCrLf
For i = 1 à l
d = i - w
Si d < 1 puis
o = o & «--»
d’autre Len(d) si = 1 then
o = o & "" & d & ""
D’autre
o = o & "" & d & ""
Fin si
End If
Si (i-1) Mod 7 = 6 alors
o = o & vbCrLf
End If
Prochaine
« Afficher les résultats
MsgBox Msg1 & vbCrLf & o,,"journées spéciales de" & MonthName(Month(DateAdd("M",1,date))) & "" & Y
« Supprimer fichier temporaire
FSO. DeleteFile(Tempfile2)
Cas 3' Ajouter Nouvelle Date
Avis = « Ajouter une Date spéciale à la liste »
Question = InputBox (« Entrez Date et nom comme » & vbCR & vbCR & « JJ/MM/AAAA nom de '''' » & vbCR & "ou" & vbCR & « MM/DD nom de '''' », avis)
« Recherchez Null ou vide inputbox puis annule
IF IsEmpty(Question) puis
WScript.quit()
Else If Len(Question) = 0 THEN
WScript.quit()
D’AUTRE
Si (fso. FileExists(FileName)) puis
Set objFile = FSO. OpenTextFile (FileName, ForAppending, True)
objFile.WriteLine (vbCrLf & Question)
D’autre
Set objFile = FSO. OpenTextFile (FileName, ForAppending, True)
objFile.WriteLine (Question)
objFile.Close
Fin si
Set arrLines = CreateObject("System.Collections.ArrayList")
« Ouvrir le fichier
Set objFile = fso. OpenTextFile (FileName, ForReading, False)
' Boucle et ajoute chaque ligne dans le tableau
Jusqu'à objFile.AtEndOfStream
strLine = Trim(objFile.ReadLine)
Si Len(strLine) > 0 Then
' Vérifier ce tableau ne disposent déjà de l’entrée
Si ce n’est arrLines.Contains(strLine) puis arrLines.Add(strLine)
Fin si
Boucle
objFile.Close
' Tri (croissant) pour l’esthétique
arrLines.Sort()
« Rejoignez le tableau avec + "\n" (transport return ou enter)
StrNewFile1 Dim : strNewFile1 = Join (arrLines.ToArray, + "\n")
« Ré-ouvrir le fichier pour la lecture
Set objFile = fso. OpenTextFile (FileName, ForWriting, False)
« Écrire le nouveau texte
objFile.Write strNewFile1
objFile.Close
MsgBox « Date spéciale et nom entré », avis
END IF
Case 4' Remove Date
Set fso = CreateObject("Scripting.FileSystemObject")
Avis = « Quel mois? »
Question = InputBox (« Tapez le numéro du mois vous souhaitez Découvre? » & vbCrLf & vbCrLf & « Entrer un numéro 1-12 », remarquez)
Set objRegEx = CreateObject("VBScript.RegExp")
DateSearch = Right(String(2,"0") & Question, 2)
objRegEx.Pattern = "^" & DateSearch
Set objFile = fso. OpenTextFile (FileName, ForReading)
« Trouver les dates dans la liste
Jusqu'à objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
Si colMatches.Count > 0 Then
Pour chaque strMatch en colMatches
MSG = Msg & "" & strSearchString & vbCrLf
Prochaine
End If
Boucle
objFile.Close
IF Len(Msg) = 0 THEN
MsgBox « Il n’y a pas de Dates dans » & MonthName(Question) & "",,"journées spéciales"
D’autre
Avis = « Tapez la Date, le nom ou les deux à enlever. »
Set objFile = fso. OpenTextFile (FileName, ForReading)
' Mettre le tableau dans InputBox
Question = InputBox (« la Date et le nom sont à la casse! » & vbCrLf & "Soyez précis, moins vous tapez plus sera mis en correspondance et supprimé." & vbCrLf & + "\n" & Msg, avis)
' Vérifier si Inputbox est vide, annuler si vide
IF IsEmpty(Question) puis
WScript.quit()
Else If Len(Question) = 0 THEN
WScript.quit()
D’AUTRE
« Supprimer l’article en Question
Set objFile = fso. OpenTextFile (FileName, ForReading)
Jusqu'à objFile.AtEndOfStream
strLine = objFile.ReadLine
Si InStr (strLine, Question) = 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Boucle
Fin si
objFile.Close
"Réécrire les éléments restants de déposer
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO. OpenTextFile (FileName, ForWriting)
objFile.Write strNewContents
objFile.Close
fin si
END SELECT
End Sub
' Gestion de message d’erreur
IF Err.Number <> 0 puis
MsgBox "vous avez entre quelque chose de mal. Réessayez. «, 0 + 16, "Ooopps... »
WScript.quit()
END IF