userform calendrier

noemie45

XLDnaute Occasionnel
Bonjour,

j'ai crée un userform où je fais apparaitre un calendrier pour sélectionner la date.
On m'a beaucoup aidé pour créer le calendrier!! et donc je ne comprend rien aux codes de mon userform
Mon problème est que la date se transforme en format mm/jj/aaaa, pour les jours avant le 12.

Par exemple : si je clique sur le 02/09/2012 la date sera 09/02/2012
mais si je clique sur le 20/09/2012 la date sera bien 20/09/2012

voici les codes de mon userform


Option Explicit

Private Declare Function CreateWindowEx Lib "user32" Alias _
"CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String _
, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long _
, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long _
, ByVal hwndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long _
, lpParam As Any) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function DestroyWindow Lib "user32" (ByVal hWnd As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long _
, lParam As Any) As Long

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long _
, ByVal hWndNewParent As Long) As Long

Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private dtHwnd As Long

Private Sub CommandButton1_Click()
Dim CurSysTime As SYSTEMTIME
SendMessage dtHwnd, &H1001, 0&, CurSysTime
With CurSysTime
MaDate = DateSerial(.wYear, .wMonth, .wDay)
End With
Unload Me
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
DestroyWindow dtHwnd
End Sub

Private Sub UserForm_Initialize()
Dim meHwnd As Long, h&
'
h = GetSystemMetrics(51)
meHwnd = FindWindow(vbNullString, Me.Caption)
dtHwnd = CreateWindowEx(0, "SysMonthCal32", vbNullString, _
&H50000000, 4, -h + 15, 235, 180, meHwnd, 0&, 0&, ByVal 0&)
SetParent dtHwnd, meHwnd
Me.Width = (Me.Width - Me.InsideWidth) + 250 * 3 / 4
CommandButton1.Top = (200 - h) * 3 / 4: CommandButton1.ZOrder 0
CommandButton1.Height = 18: CommandButton1.Width = 60
CommandButton1.Caption = "VALIDER"
Me.Height = CommandButton1.Top + CommandButton1.Height + GetSystemMetrics(4) + 6
Me.Width = CommandButton1.Left + 6 + CommandButton1.Width + GetSystemMetrics(7) * 3 / 2
End Sub



merci pour votre aide
 

Discussions similaires

Statistiques des forums

Discussions
312 378
Messages
2 087 755
Membres
103 658
dernier inscrit
Laurent2017