Public region As Variant 'region 0,1,2,"US","FR","CA"
Public Result As Variant ' ou date ou ancienne date ou rien
Dim posLeft As Long, posTop As Long, Obj As Object, Oldvalue
Public WithEvents Bout As MSForms.Label 'map pour 42 bouton
Private clavier(43) As New calendar 'tableau d'instance de l'userform
Private Sub UserForm_Activate()
config
placementRange Obj
Oldvalue = Obj.Value
ldate = IIf(region > 0, "Aujourd'hui", "Todays is") & vbCrLf & IIf(region = 0, Format(Date, "mm/dd/yyyy"), IIf(region = 1, Date, Format(Date, "yyyy-mm-dd")))
Me.Caption = IIf(region = 0, "Calendar", "Calendrier")
'mappage pour evenement unique (42 boutons) (intra userform sans module classe)
For I = 1 To 42: Set clavier(I).Bout = Me.Controls("j" & I): Next
End Sub
'événement unique pour 42 boutons
Private Sub bout_Click(): putDate Bout: End Sub
Public Sub putDate(ByVal q As Object)
forme = Switch(region = 0, "mm/dd/yyyy", region = 1, "dd/mm/yyyy", region = 2, "yyyy-mm-dd")
If TypeName(Obj) = "Range" Then
calendar.Result = DateSerial(calendar.Cbyear.Value, calendar.Cbmonth.ListIndex + 1, q.Caption)
Else
calendar.Result = Format(DateSerial(calendar.Cbyear.Value, calendar.Cbmonth.ListIndex + 1, q.Caption), forme)
End If
calendar.Hide
End Sub
Public Sub ShowX(Optional ObjX As Object, Optional PlX As Double, Optional Ply As Double, Optional PLeft As Long = 0, Optional Ptop As Long = 0)
'''Me.startupposition = 0
posLeft = PlX: posTop = Ply
Set Obj = ObjX
Me.Show
End Sub