| MHack |
| | Questa è la mia funzione: CODICE ;$g = giorno del mese ;$M = numero del mese (da wikipedia);Gennaio = 0 (se l'anno è bisestile = 6),Febbraio = 3 (se l'anno è bisestile = 2),Marzo = 3 (se l'anno è bisestile = 4),Aprile = 6, ;Maggio = 1,Giugno = 4,Luglio = 6,Agosto = 2,Settembre = 5,Ottobre = 0, Novembre = 3,Dicembre = 5 ;$s = prime due cifre dell'anno ;$a = ultime due cifre dell'anno _CalendarioP(1,0,20,11) Func _CalendarioP($g,$M,$s,$a) $G = Mod($g,7) $A = Mod($a,28) + Int(((Mod($a,28) -1)/4)) $C = "" If Mod($s,4) = 0 Then $C = 6 ElseIf Mod($s,4) = 1 Then $C = 4 ElseIf Mod($s,4) = 2 Then $C = 2 ElseIf Mod($s,4) = 3 Then $C = 0 EndIf $tot = $G+$M+$A+$C $day = Mod($tot,7) If $day = 0 Then MsgBox(0,"","domenica") ElseIf $day = 1 Then MsgBox(0,"","lunedì") ElseIf $day = 2 Then MsgBox(0,"","martedì") ElseIf $day = 3 Then MsgBox(0,"","mercoledì") ElseIf $day = 4 Then MsgBox(0,"","giovedì") ElseIf $day = 5 Then MsgBox(0,"","venerdì") ElseIf $day = 6 Then MsgBox(0,"","sabato") Else MsgBox(16,"","errore "&@error) EndIf EndFunc Non è migliorata come funzione, nel senso che non puoi inserire direttamente il numero del mese, ma quello di $M. Versione 2 xD CODICE #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3>
$gui = GUICreate("Calendario Perpetuo",295,100,-1,-1) GUISetState(@SW_SHOW)
;label $lgiorno = GUICtrlCreateLabel("Giorno:",16,8,38,17) $lmese = GUICtrlCreateLabel("Mese:",112,8,33,17) $lanno = GUICtrlCreateLabel("Anno:",192,8,32,17) $lris = GUICtrlCreateLabel("",8,80,280,17)
;input $giorno = GUICtrlCreateInput("",56,8,41,21) GUICtrlSetTip(-1,"Inserire il numero del giorno del mese(es. 12)") GUICtrlSetLimit(-1,31,1) $mese = GUICtrlCreateInput("",144,8,41,21) GUICtrlSetTip(-1,"Inserire il numero del mese (es. Aprile = 4)") GUICtrlSetLimit(-1,12,1) $anno = GUICtrlCreateInput("",232,8,41,21)
;button $get = GUICtrlCreateButton("Calcola",112,45,75,25)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $get $g = GUICtrlRead($giorno) $read_anno = GUICtrlRead($anno) $read_mese = GUICtrlRead($mese) $M = "" _ReplaceM() If $g And $read_anno And $read_mese <> "" Then $a = Mod($read_anno,100) $s = Int($read_anno/100) _CalendarioP($g,$M,$s,$a) GUICtrlSetData($lris,"Il giorno "&$g&"/"&$read_mese&"/"&$read_anno&" sarà (o è stato) un "&$days[$day]) Else MsgBox(16,"","Errore! Riempi tutti i campi!") EndIf EndSwitch WEnd
Func _ReplaceM() $read_mese = GUICtrlRead($mese) If $read_mese = 1 Or 01 Then If Mod($read_anno,4) <> 0 Then $M = 0 Else $M = 6 EndIf ElseIf $read_mese = 2 Or 02 Then If Mod($read_anno,4) <> 0 Then $M = 3 Else $M = 2 EndIf ElseIf $read_mese = 3 Or 03 Then If Mod($read_anno,4) <> 0 Then $M = 3 Else $M = 4 EndIf ElseIf $read_mese = 4 Or 04 Then $M = 6 ElseIf $read_mese = 5 Or 05 Then $M = 1 ElseIf $read_mese = 6 Or 06 Then $M = 4 ElseIf $read_mese = 7 Or 07 Then $M = 6 ElseIf $read_mese = 8 Or 08 Then $M = 2 ElseIf $read_mese = 9 Or 09 Then $M = 5 ElseIf $read_mese = 10 Then $M = 0 ElseIf $read_mese = 11 Then $M = 3 ElseIf $read_mese = 12 Then $M = 5 EndIf EndFunc
Func _CalendarioP($g,$M,$s,$a) $G = Mod($g,7) $A = Mod($a,28) + Int(((Mod($a,28) -1)/4)) $C = "" If Mod($s,4) = 0 Then $C = 6 ElseIf Mod($s,4) = 1 Then $C = 4 ElseIf Mod($s,4) = 2 Then $C = 2 ElseIf Mod($s,4) = 3 Then $C = 0 EndIf $tot = $G+$M+$A+$C Global $day = Mod($tot,7) Global $days[7]=["domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"] MsgBox(0,"",$days[$day]) EndFunc Versione 2.1 (xD)CODICE #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3>
$gui = GUICreate("Calendario Perpetuo",295,100,-1,-1) GUISetState(@SW_SHOW)
;label $lgiorno = GUICtrlCreateLabel("Giorno:",16,8,38,17) $lmese = GUICtrlCreateLabel("Mese:",112,8,33,17) $lanno = GUICtrlCreateLabel("Anno:",192,8,32,17) $lris = GUICtrlCreateLabel("",8,80,280,17)
;input $giorno = GUICtrlCreateInput("",56,8,41,21) GUICtrlSetTip(-1,"Inserire il numero del giorno del mese(es. 12)") GUICtrlSetLimit(-1,31,1) $mese = GUICtrlCreateInput("",144,8,41,21) GUICtrlSetTip(-1,"Inserire il numero del mese (es. Aprile = 4)") GUICtrlSetLimit(-1,12,1) $anno = GUICtrlCreateInput("",232,8,41,21)
;button $get = GUICtrlCreateButton("Calcola",112,45,75,25)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $get $g = GUICtrlRead($giorno) $read_anno = GUICtrlRead($anno) $read_mese = GUICtrlRead($mese) $M = "" _ReplaceM() If $g And $read_anno And $read_mese <> "" Then $a = Mod($read_anno,100) $s = Int($read_anno/100) _CalendarioP($g,$M,$s,$a) If @YEAR&@MON&@MDAY > $read_anno&$read_mese&$g Then GUICtrlSetData($lris,"Il giorno "&$g&"/"&$read_mese&"/"&$read_anno&" è stato "&$days[$day]) ElseIf @YEAR&@MON&@MDAY < $read_anno&$read_mese&$g Then GUICtrlSetData($lris,"Il giorno "&$g&"/"&$read_mese&"/"&$read_anno&" sarà "&$days[$day]) Else GUICtrlSetData($lris,"Oggi è "&$days[$day]) EndIf Else MsgBox(16,"","Errore! Riempi tutti i campi!") EndIf EndSwitch WEnd
Func _ReplaceM() $read_mese = GUICtrlRead($mese) If $read_mese = 1 Or 01 Then If Mod($read_anno,4) <> 0 Then $M = 0 Else $M = 6 EndIf ElseIf $read_mese = 2 Or 02 Then If Mod($read_anno,4) <> 0 Then $M = 3 Else $M = 2 EndIf ElseIf $read_mese = 3 Or 03 Then If Mod(Mod($read_anno,100),4) <> 0 Then $M = 3 Else $M = 4 EndIf ElseIf $read_mese = 4 Or 04 Then $M = 6 ElseIf $read_mese = 5 Or 05 Then $M = 1 ElseIf $read_mese = 6 Or 06 Then $M = 4 ElseIf $read_mese = 7 Or 07 Then $M = 6 ElseIf $read_mese = 8 Or 08 Then $M = 2 ElseIf $read_mese = 9 Or 09 Then $M = 5 ElseIf $read_mese = 10 Then $M = 0 ElseIf $read_mese = 11 Then $M = 3 ElseIf $read_mese = 12 Then $M = 5 EndIf EndFunc
Func _CalendarioP($g,$M,$s,$a) ;$g = giorno del mese ;$M = numero del mese (da wikipedia);Gennaio = 0 (se l'anno è bisestile = 6),Febbraio = 3 (se l'anno è bisestile = 2),Marzo = 3 (se l'anno è bisestile = 4),Aprile = 6, ;Maggio = 1,Giugno = 4,Luglio = 6,Agosto = 2,Settembre = 5,Ottobre = 0, Novembre = 3,Dicembre = 5 ;$s = prime due cifre dell'anno ;$a = ultime due cifre dell'anno $G = Mod($g,7) $A = Mod($a,28) + Int(((Mod($a,28) -1)/4)) $C = "" If Mod($s,4) = 0 Then $C = 6 ElseIf Mod($s,4) = 1 Then $C = 4 ElseIf Mod($s,4) = 2 Then $C = 2 ElseIf Mod($s,4) = 3 Then $C = 0 EndIf $tot = $G+$M+$A+$C Global $day = Mod($tot,7) Global $days[7]=["domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"] MsgBox(0,"",$days[$day]) EndFunc Edited by MHack - 3/1/2011, 12:28
| | |
| |
|