IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Un calendar pour tous ( control calendrier ) [Toutes versions]


Sujet :

Macros et VBA Excel

  1. #1
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut Un calendar pour tous ( control calendrier )
    Bonsoir

    pour les utilisateur office 64 bits les contrôles pour les calendriers ne fonctionnent pas

    alors je vous en ai fait un en version beta mais fonctionnel a 100%

    je créé tout les boutons en dynamique dans une petite classe

    nous allons commencer par ajouter un tex box dans notre userform et oui je dit bien un tex box et de la taille dont vous voulez que le calendrier prenne

    dans l'exemple que je fourni vous verrez que j'ai mémé poussé le vice en nommant ce textbox "calendar" la bonne blague ) vous l'appellerez comme bon vous semble puisque que c'est le 2 argument de la fonction

    alors voila maintenant que l'on a mis notre textbox heu.. non!!!! calendar heu.....

    dans le module userform on va mettre dans le activate ceci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    Dim cl As New calendrier
     
    Private Sub UserForm_Activate()
    cl.creation_calandrier Me, Me.calendar
    End Sub
    les deux argument sont des object (l'userform et le textbox )

    afin qu'il puisse se comporter comme si il en était vraiment un je vais utiliser l'évènement change du textbox heu... calendar heu......
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Sub calendar_Change()
    MsgBox calendar
    End Sub
    voila pour l'userform c'est fini

    maintenant passons a la classe

    voici le code
    le principe est très simple
    j'ajoute une frame au dimensions et place du textbox il sera donc caché
    j'ajoute 2 combobox (mois et année )
    et pour finir les 31 boutons possible pour 31 jour voir 28 ou 29 pour février le tout automatiquement bien sur

    tout les contrôles sont proportionné par rapport a la frame donc quelque dimensions que se soit le calendrier sera entier le tout automatiquement bien sur

    et pour finir on gère les évènement clik et move des( boutons / frame )

    donc en voici le code de cette classe que l'on nommera j'te l' donne dans l'mille "calendrier" (non vraiment ils sont fous ces toulonnais )
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
     
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Private jr(31) As New calendrier
    Public usf As UserForm
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr)
        Dim fram As Object, listm As Object, lista As Object, i As Long, widthbout As Long, heightbout As Long, thetop As Long, leleft, bout As Object
        Set jr(0).formm = uf
        Set fram = uf.Add("Forms.Frame.1", "cal")
        fram.Move ctr.Left, ctr.Top, ctr.Width, ctr.Height
        fram.BackColor = RGB(80, 80, 80)
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 8: .TextAlign = 1: .Move 0, 0, fram.Width / 4 * 2, 15
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            .ListIndex = Month(Date) - 1
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .Move listm.Width, 0, fram.Width / 4 * 2, 15
            For i = 1 To 30: .AddItem 2000 + 1 * i: Next
            .ListIndex = 15
        End With
        '**********************************************************************************************************************
        widthbout = (fram.Width - 8) / 8
        heightbout = (fram.Height - 30 - 12) / 5
        thetop = 20
        leleft = 2
        For i = 1 To NB_JOURS(listm.ListIndex + 1, lista.Value)
            Set bout = fram.Add("Forms.Label.1", "jour" & i)
            Set jr(i).JRS = bout: Set jr(i).listeA = lista: Set jr(i).listeM = listm
            Set jr(i).formm = uf: Set jr(i).frame = fram
            Set jr(i).calendart = uf.Controls("calendar")
            With bout
                .Caption = i: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(150, 0, 180): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = 6
                .Move leleft, thetop, widthbout, heightbout
                leleft = leleft + widthbout + fram.Width / 52
                If i = 7 Or i = 14 Or i = 21 Or i = 28 Then thetop = thetop + heightbout + fram.Height / 34: leleft = 2
            End With
        Next
    End Function
    Private Sub JRS_Click()
        calendart.Value = DateSerial(listeA.Value, listeM.ListIndex + 1, JRS)
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
     
            JRS.BackColor = RGB(200, 200, 10)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
            frame.Tag = ""
        End If
    End Sub
    voila la démo en image
    Nom : demo2.gif
Affichages : 3085
Taille : 904,2 Ko

    le fichier en pièce jointe
    Fichiers attachés Fichiers attachés
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  2. #2
    Expert éminent Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Points : 9 548
    Points
    9 548
    Par défaut
    Bonsoir Patrick,
    Bravo pour le boulot mais, après avoir fait un test, perso, j'ai un bug dans cette procédure
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Function creation_calendrier(uf, ctr)
    .....
    .....
    .Move leleft, thetop, widthbout, heightbout
    et je crois que ça vient de cette variable "heightbout" qui est à "-2" chez moi
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  3. #3
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    Bonjour casefayere

    je comprends pas il est impossible que heightbout soit negatif je vais faire des essais
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  4. #4
    Expert éminent Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Points : 9 548
    Points
    9 548
    Par défaut
    et moi, je vais le refaire sur mon autre PC (un portable récent) et te dirais quoi
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  5. #5
    Expert éminent Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Points : 9 548
    Points
    9 548
    Par défaut
    avec mes excuses, en le faisant sur l'autre PC, j'ai compris qu'il fallait tirer plus le textbox, maintenant impeccable
    encore bravo, j'espère ne pas t'avoir fait stresser
    bonne nuit
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  6. #6
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    oui je n'est pas prévu de limite minimale de taille mais bon si on veux que ce soit lisible il faut un minimum

    en fait l'erreur est provoqué par les -30-12
    si le txtbox ne fait au moins 43
    je vais donc remplacer ca par un prorata
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  7. #7
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    voila correction
    pour le heightbout
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    heightbout = (fram.Height - fram.Height / 2.42) / 5
    après une taille minimum sur le textbox pour une lisibilité est requise quand même

    merci casefayere car c'était bien un problème de conception une belle erreur de ma part

    2 points pour toi
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  8. #8
    Expert éminent Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Points : 9 548
    Points
    9 548
    Par défaut
    j'ai corrigé et gardé sous le coude, on ne sait jamais ! si tu autorises à le diffuser.....(en citant l'auteur, bien sur)

    re bonne nuit
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  9. #9
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    re oui y a pas de soucis distribue (en citant l'auteur et pourquoi pas le lien a fin d'avoir le plus de retours possible pour d'éventuelles améliorations
    tiens j'ai corrigé plein de petite chose tout du moins j'ai mis au prorata plutôt qu'utiliser des nombre y compris pour les font size

    en attendant la version 1.0 le voila tout corrigé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Private jr(31) As New calendrier
    Public usf As UserForm
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr)
        Dim fram As Object, listm As Object, lista As Object, i As Long, widthbout As Long, heightbout As Long, thetop As Long, leleft, bout As Object
        Set jr(0).formm = uf
        Set fram = uf.Add("Forms.Frame.1", "cal")
        fram.Move ctr.Left, ctr.Top, ctr.Width, ctr.Height
        fram.BackColor = RGB(80, 80, 80)
        fram.BorderStyle = 1
        fram.BorderColor = vbBlue
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 8: .TextAlign = 1: .Move 0, 0, fram.Width / 4 * 2, 15: .BackColor = RGB(50, 0, 125): .ForeColor = RGB(255, 255, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            '.ListIndex = Month(Date) - 1
        .Value = Format(Date, "mmmm"): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .Move listm.Width, 0, fram.Width / 4 * 2, 15: .BackColor = RGB(50, 0, 125): .ForeColor = RGB(255, 255, 0): .ListRows = 15
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            '.ListIndex = 15
        .Value = Year(Date)
        End With
        '**********************************************************************************************************************
        widthbout = (fram.Width - 8) / 7.87
        heightbout = ((fram.Height - 20) - (fram.Height / 11) - fram.Height / 8) / 5
        thetop = 20
        leleft = 2
        For i = 1 To NB_JOURS(listm.ListIndex + 1, lista.Value)
            Set bout = fram.Add("Forms.Label.1", "jour" & i)
            Set jr(i).JRS = bout: Set jr(i).listeA = lista: Set jr(i).listeM = listm
            Set jr(i).formm = uf: Set jr(i).frame = fram
            Set jr(i).calendart = uf.Controls("calendar")
            With bout
     
                .Caption = i: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(150, 0, 180): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(widthbout / (widthbout / 6))
                .Move leleft, thetop, widthbout, heightbout
                leleft = leleft + widthbout + fram.Width / 52
                If i = 7 Or i = 14 Or i = 21 Or i = 28 Then thetop = thetop + heightbout + fram.Height / 33: leleft = 2
             End With
        Next
    End Function
    Private Sub JRS_Click()
        calendart.Value = DateSerial(listeA.Value, listeM.ListIndex + 1, JRS)
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
     
            JRS.BackColor = RGB(200, 200, 10)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
            frame.Tag = ""
        End If
    End Sub
    ca va faire plaisir a ce qui ont un office 64 bits hein !!!!
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  10. #10
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    allez nouveau!!!!
    changement des boutons jour au grès des comboboxs

    suppression des jours non valide
    exemple février de 2016 =29 jours
    suppression du 31 si mois en 30 jours

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Private jr(31) As New calendrier
    Public usf As UserForm
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr)
        Dim fram As Object, listm As Object, lista As Object, i As Long, widthbout As Long, heightbout As Long, thetop As Long, leleft, bout As Object
        Set jr(0).formm = uf
        Set fram = uf.Add("Forms.Frame.1", "cal")
        With fram: .Move ctr.Left, ctr.Top, ctr.Width, ctr.Height: .BackColor = RGB(80, 80, 80): .BorderStyle = 1: .BorderColor = vbBlue: End With
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 8: .TextAlign = 1: .Move 0, 0, fram.Width / 4 * 2, 15: .BackColor = RGB(50, 0, 125): .ForeColor = RGB(255, 255, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            '.ListIndex = Month(Date) - 1
        .Value = Format(Date, "mmmm"): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .Move listm.Width, 0, fram.Width / 4 * 2, 15: .BackColor = RGB(50, 0, 125): .ForeColor = RGB(255, 255, 0): .ListRows = 15
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            '.ListIndex = 15
        .Value = Year(Date)
        End With
        '**********************************************************************************************************************
        widthbout = (fram.Width - 8) / 7.87
        heightbout = ((fram.Height - 20) - (fram.Height / 11) - fram.Height / 8) / 5
        thetop = 20
        leleft = 2
        For i = 1 To NB_JOURS(listm.ListIndex + 1, lista.Value)
            Set bout = fram.Add("Forms.Label.1", "jour" & i)
                   Set jr(i).JRS = bout: Set jr(i).listeA = lista: Set jr(i).listeM = listm
            Set jr(i).formm = uf: Set jr(i).frame = fram
            Set jr(i).calendart = uf.Controls("calendar")
            Set jr(i).listeM = listm
     
            With bout
     
                .Caption = i: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(150, 0, 180): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(widthbout / (widthbout / 6))
                .Move leleft, thetop, widthbout, heightbout
                leleft = leleft + widthbout + fram.Width / 52
                If i = 7 Or i = 14 Or i = 21 Or i = 28 Then thetop = thetop + heightbout + fram.Height / 33: leleft = 2
             End With
        Next
    End Function
    Private Sub JRS_Click()
        calendart.Value = DateSerial(listeA.Value, listeM.ListIndex + 1, JRS)
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
     
            JRS.BackColor = RGB(200, 200, 10)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
            frame.Tag = ""
        End If
    End Sub
    Private Sub listeM_Change()
    changebout
    End Sub
    Private Sub listeA_Change()
    changebout
    End Sub
    Sub changebout()
    'MsgBox NB_JOURS(formm.Controls("listemois").ListIndex + 1, formm.Controls("listeAnnée").Value)
    Dim ctrl, i As Long
    For Each ctrl In formm.Controls("cal").Controls
    If ctrl.Name Like "*jour*" Then
    i = i + 1: ctrl.Caption = ""
    If i <= Val(NB_JOURS(formm.Controls("listemois").ListIndex + 1, formm.Controls("listeAnnée").Value)) Then ctrl.Caption = i
    End If
    Next
    End Sub
    Nom : demo2.gif
Affichages : 3041
Taille : 220,3 Ko
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  11. #11
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    re
    correction sur le clik du bouton vide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Private jr(31) As New calendrier
    Public usf As UserForm
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr)
        Dim fram As Object, listm As Object, lista As Object, i As Long, widthbout As Long, heightbout As Long, thetop As Long, leleft, bout As Object
        Set jr(0).formm = uf
        Set fram = uf.Add("Forms.Frame.1", "cal")
        With fram: .Move ctr.Left, ctr.Top, ctr.Width, ctr.Height: .BackColor = RGB(80, 80, 80): .BorderStyle = 1: .BorderColor = vbBlue: End With
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 8: .TextAlign = 1: .Move 0, 0, fram.Width / 4 * 2, 15: .BackColor = RGB(50, 0, 125): .ForeColor = RGB(255, 255, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            '.ListIndex = Month(Date) - 1
        .Value = Format(Date, "mmmm"): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .Move listm.Width, 0, fram.Width / 4 * 2, 15: .BackColor = RGB(50, 0, 125): .ForeColor = RGB(255, 255, 0): .ListRows = 15
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            '.ListIndex = 15
        .Value = Year(Date)
        End With
        '**********************************************************************************************************************
        widthbout = (fram.Width - 8) / 7.87
        heightbout = ((fram.Height - 20) - (fram.Height / 11) - fram.Height / 8) / 5
        thetop = 20
        leleft = 2
        For i = 1 To NB_JOURS(listm.ListIndex + 1, lista.Value)
            Set bout = fram.Add("Forms.Label.1", "jour" & i)
                   Set jr(i).JRS = bout: Set jr(i).listeA = lista: Set jr(i).listeM = listm
            Set jr(i).formm = uf: Set jr(i).frame = fram
            Set jr(i).calendart = uf.Controls("calendar")
            Set jr(i).listeM = listm
     
            With bout
     
                .Caption = i: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(150, 0, 180): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(widthbout / (widthbout / 6))
                .Move leleft, thetop, widthbout, heightbout
                leleft = leleft + widthbout + fram.Width / 52
                If i = 7 Or i = 14 Or i = 21 Or i = 28 Then thetop = thetop + heightbout + fram.Height / 33: leleft = 2
             End With
        Next
    End Function
    Private Sub JRS_Click()
        If JRS.Caption = "" Then Exit Sub
        calendart.Value = DateSerial(listeA.Value, listeM.ListIndex + 1, JRS)
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
     
            JRS.BackColor = RGB(200, 200, 10)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120)
            frame.Tag = ""
        End If
    End Sub
    Private Sub listeM_Change()
    changebout
    End Sub
    Private Sub listeA_Change()
    changebout
    End Sub
    Sub changebout()
    'MsgBox NB_JOURS(formm.Controls("listemois").ListIndex + 1, formm.Controls("listeAnnée").Value)
    Dim ctrl, i As Long
    For Each ctrl In formm.Controls("cal").Controls
    If ctrl.Name Like "*jour*" Then
    i = i + 1: ctrl.Caption = ""
    If i <= Val(NB_JOURS(formm.Controls("listemois").ListIndex + 1, formm.Controls("listeAnnée").Value)) Then ctrl.Caption = i
    End If
    Next
    End Sub
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  12. #12
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re nouveau !!!!
    Bonjour a tous

    voila la version 2.0 (finale)

    nouveauté:
    1. ajout de la ligne d'entête colonne (noms des jours en abrégés)
    2. placement des jours dans leur colonnes respectives
    3. mise en évidence(en vert) du jour correspondant a la date du jour
    4. effet mouse over revu et amélioré
    5. ajout combo box du choix du format de sortie
    6. design plus joli
    apercu
    Nom : demo2.gif
Affichages : 2978
Taille : 896,1 Ko

    code de la classe :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
     
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Public WithEvents listeF As MSForms.ComboBox
    Private jr(42) As New calendrier
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr)
        Dim fram As Object, listm As Object, lista As Object, listf As Object, i As Long, Wbt As Long, HbT As Long, thetop As Long, leleft, bout, jourr, lig, col, formT
        jourr = Array("lun.", "mar.", "mer.", "jeu.", "ven.", "sam.", "dim.")
        formT = Array("FORMAT", "dd/mm/yyyy", "yyyy/mm/dd", "ddd dd mmm yyyy", "dddd dd mmmm yyyy")
        Set fram = uf.Add("Forms.Frame.1", "cal")
        With fram: .Move ctr.Left, ctr.Top, ctr.Width, ctr.Height: .BackColor = RGB(80, 80, 80): .BorderStyle = 1: .BorderColor = vbBlue: End With
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 9: .TextAlign = 1: .Move 0, 0, fram.Width / 3, 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            .Value = Format(Date, "mmmm"): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move listm.Width, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0):
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            .Value = Year(Date): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox choix du format de sortie de la date ***************************************************
        Set listf = fram.Add("Forms.combobox.1", "listeFormat")
        With listf
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move (fram.Width / 3) * 2, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0):
            .List = formT
            .ListIndex = 0
        End With
        '**********************************************************************************************************************
        ' dimention aux proportions
        Wbt = (fram.Width) / 7: HbT = (fram.Height - 41) / 6
        thetop = 20: leleft = 1
        For i = 0 To UBound(jourr)    ' ajout de la ligne d'entetes  pour les jours en lettre
            Set bout = fram.Add("Forms.lABEL.1", jourr(i))
            With bout
                .Caption = jourr(i): .Tag = i + 1: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(70, 70, 70): .BorderColor = RGB(0, 200, 255): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(HbT / 2): .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                .Move leleft + (Wbt * i) - 1 * i, thetop, Wbt, Round(fram.Height / 8)
            End With
        Next
        leleft = 1
        thetop = fram.Controls("lun.").Top + fram.Controls("lun.").Height + 2
        i = 0
        For lig = 1 To 6
            For col = 0 To 6
                i = i + 1
                Set bout = fram.Add("Forms.Label.1", "jour" & i)
                With bout
                    .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(255, 255, 255): .ForeColor = RGB(255, 255, 255)
                    .TextAlign = 2: .FontSize = Round(HbT / 2)
                    .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                    .Move leleft + (Wbt * col) - 1 * col, thetop, Wbt, Round(fram.Height / 8)
                    'ajout des liste,frame,userform,textbox dans l'instance(i) de la classe calendrier du label
                    With jr(i): Set .JRS = bout: Set .listeA = lista: Set .listeM = listm: Set .listeF = listf: Set .formm = uf: Set .frame = fram: Set .calendart = uf.Controls("calendar"): End With
                End With
                If col = 6 Or col = 14 Or col = 21 Or col = 28 Or col = 35 Or col = 42 Then thetop = thetop + HbT: leleft = 1
            Next col
        Next lig
        fram.Height = fram.Controls("jour42").Top + fram.Controls("jour42").Height + 3
        mise_a_jour fram
    End Function
    Private Sub JRS_Click()
        If listeF.ListIndex < 1 Then listeF.ListIndex = 1
        If JRS.Caption = "" Then Exit Sub
        If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 150, 0)
        calendart.Value = Format(DateSerial(listeA.Value, listeM.ListIndex + 1, JRS), listeF.Value)
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then
                frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
                If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            End If
            If JRS.Caption <> "" Then JRS.BackColor = RGB(100, 100, 100): JRS.BorderColor = RGB(0, 200, 255)
            If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 0, 100)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
            If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            frame.Tag = ""
        End If
    End Sub
    Private Sub listeM_Change()
        mise_a_jour listeM.Parent
    End Sub
    Private Sub listeA_Change()
        mise_a_jour listeM.Parent
    End Sub
    Sub mise_a_jour(fram)
        Dim ctrl, i As Long, jj, decal
        For i = 1 To 42: fram.Controls("jour" & i).Caption = "": Next
        decal = Val(fram.Controls(Format(DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, 1), "ddd")).Tag)
        For i = 1 To NB_JOURS(fram.Controls("listemois").ListIndex + 1, fram.Controls("listeAnnée").Value)
            fram.Controls("jour" & i + decal - 1) = i
            If DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, i) = Date Then fram.Controls("jour" & i + decal - 1).ForeColor = vbGreen Else fram.Controls("jour" & i + decal - 1).ForeColor = vbWhite
        Next
    End Sub
    et toujours dans le userform
    calendar est toujours un textbox
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
     
    Dim cl As New calendrier
    Private Sub calendar_Change()
    MsgBox calendar
    End Sub
     
    Private Sub UserForm_Activate()
    cl.creation_calandrier Me, Me.calendar
    End Sub
    vous en pensez quoi de celui la !!
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  13. #13
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    oui c'est possible en l'état je vais voir si j'ai le dtpiker et voir comment il se comporte
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  14. #14
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re version pour case fayere
    re
    voila tu met dans l'éditeur vbe ton textbox a la taille que doit avoir ton calendrier même si dans le même endroit il y a d'autre contrôles
    et la classe s'occupe de tout
    module userform
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    Dim cl As New calendrier
    Private Sub calendar_Change()
    'MsgBox calendar
    End Sub
    Private Sub calendar_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Me.Controls("cal").Visible = True
    End Sub
     
    Private Sub UserForm_Activate()
    cl.creation_calandrier Me, Me.calendar
    End Sub
    module classe "calendrier"
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
     
     
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Public WithEvents listeF As MSForms.ComboBox
    Private jr(42) As New calendrier
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr)
        Dim fram As Object, listm As Object, lista As Object, listf As Object, i As Long, Wbt As Long, HbT As Long, thetop As Long, leleft, bout, jourr, lig, col, formT
        jourr = Array("lun.", "mar.", "mer.", "jeu.", "ven.", "sam.", "dim.")
        formT = Array("FORMAT", "dd/mm/yyyy", "dd-mm-yyyy", "d/m/yy", "yyyy/mm/dd", "yyyy-mm-dd", "ddd dd mmm yyyy", "dddd dd mmmm yyyy")
        Set fram = uf.Add("Forms.Frame.1", "cal")
        With fram: .Move ctr.Left, ctr.Top, ctr.Width, ctr.Height: .BackColor = RGB(80, 80, 80): .BorderStyle = 1: .BorderColor = vbBlue: End With
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 9: .TextAlign = 1: .Move 0, 0, fram.Width / 3, 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            .Value = Format(Date, "mmmm"): .BorderStyle = 1: .ListRows = UBound(formT)
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move listm.Width, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0):
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            .Value = Year(Date): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox choix du format de sortie de la date ***************************************************
        Set listf = fram.Add("Forms.combobox.1", "listeFormat")
        With listf
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move (fram.Width / 3) * 2, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0):
            .List = formT
            .ListIndex = 0
        End With
        '**********************************************************************************************************************
        ' dimention aux proportions
        Wbt = (fram.Width) / 7: HbT = (fram.Height - 41) / 6
        thetop = 20: leleft = 1
        For i = 0 To UBound(jourr)    ' ajout de la ligne d'entetes  pour les jours en lettre
            Set bout = fram.Add("Forms.lABEL.1", jourr(i))
            With bout
                .Caption = jourr(i): .Tag = i + 1: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(70, 70, 70): .BorderColor = RGB(0, 200, 255): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(HbT / 2): .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                .Move leleft + (Wbt * i) - 1 * i, thetop, Wbt, Round(fram.Height / 8)
            End With
        Next
        leleft = 1
        thetop = fram.Controls("lun.").Top + fram.Controls("lun.").Height + 2
        i = 0
        For lig = 1 To 6
            For col = 0 To 6
                i = i + 1
                Set bout = fram.Add("Forms.Label.1", "jour" & i)
                With bout
                    .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(255, 255, 255): .ForeColor = RGB(255, 255, 255)
                    .TextAlign = 2: .FontSize = Round(HbT / 2)
                    .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                    .Move leleft + (Wbt * col) - 1 * col, thetop, Wbt, Round(fram.Height / 8)
                    'ajout des liste,frame,userform,textbox dans l'instance(i) de la classe calendrier du label
                    With jr(i): Set .JRS = bout: Set .listeA = lista: Set .listeM = listm: Set .listeF = listf: Set .formm = uf: Set .frame = fram: Set .calendart = uf.Controls("calendar"): End With
                End With
                If col = 6 Or col = 14 Or col = 21 Or col = 28 Or col = 35 Or col = 42 Then thetop = thetop + HbT: leleft = 1
            Next col
        Next lig
        fram.Height = fram.Controls("jour42").Top + fram.Controls("jour42").Height + 3
        mise_a_jour fram
    fram.Visible = False
    ctr.Height = 20
    End Function
    Private Sub JRS_Click()
        If listeF.ListIndex < 1 Then listeF.ListIndex = 1
        If JRS.Caption = "" Then Exit Sub
        If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 150, 0)
        calendart.Value = Format(DateSerial(listeA.Value, listeM.ListIndex + 1, JRS), listeF.Value)
    frame.Visible = False
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then
                frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
                If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            End If
            If JRS.Caption <> "" Then JRS.BackColor = RGB(100, 100, 100): JRS.BorderColor = RGB(0, 200, 255)
            If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 0, 100)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
            If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            frame.Tag = ""
        End If
    End Sub
    Private Sub listeM_Change()
        mise_a_jour listeM.Parent
    End Sub
    Private Sub listeA_Change()
        mise_a_jour listeM.Parent
    End Sub
    Sub mise_a_jour(fram)
        Dim ctrl, i As Long, jj, decal
        For i = 1 To 42: fram.Controls("jour" & i).Caption = "": Next
        decal = Val(fram.Controls(Format(DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, 1), "ddd")).Tag)
        For i = 1 To NB_JOURS(fram.Controls("listemois").ListIndex + 1, fram.Controls("listeAnnée").Value)
            fram.Controls("jour" & i + decal - 1) = i
            If DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, i) = Date Then fram.Controls("jour" & i + decal - 1).ForeColor = vbGreen Else fram.Controls("jour" & i + decal - 1).ForeColor = vbWhite
        Next
    End Sub
    appercu
    Nom : demo2.gif
Affichages : 3108
Taille : 468,3 Ko
    Fichiers attachés Fichiers attachés
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  15. #15
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    re

    nouveauté !!! position relative
    Bonjour a tous d'après l'idée de casefayere de le rendre visible l'ors du click sur le textbox date j'ai revu le placement


    en effet si le textbox date est trop prêt du bord droite du userform le userform peut etre tronqué
    j'ai donc ajouter le calcul du placement dynamique

    si le textbox et suffisamment loin du bord droite et du bord bottom du userform c'est bon il s'affiche au top et left du textbox sinon il calcul par rapport a sa dimension et se met juste au dessus du top et a sa largeur +10 de la droite

    bien entendu cela m'a permis aussi de dissocier a grès de l'utilisateur la largeur du textbox
    en effet la largeur du calendar était identique au textbox ce qui obligeait d' élargir la textbox si on voulait en grand format
    maintenant c'est un 3 eme argument dans l'appel de la classe
    alors soit on met nomtexbox.width ou un nombre

    j'ai aussi ajouter le click du calendar dans la classe il ne reste plus que le activate dans le userform

    code userform
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    Dim cl As New calendrier
    Private Sub calendar_Change()
    'MsgBox calendar
    End Sub
    Private Sub UserForm_Activate()
    cl.creation_calandrier Me, Me.calendar
    ' si on le veut plus grand 
    'cl.creation_calandrier Me, Me.calendar,250
    'ou
    'si on veut l'adapter eu textbox 
    'cl.creation_calandrier Me, Me.calendar,me.calendar.width   ' calendar étant le nom du textbox 
    End Sub
    code de la classe

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
     
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Public WithEvents listeF As MSForms.ComboBox
    Private jr(42) As New calendrier
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr, Optional large As Long = 140)
        Dim fram As Object, listm As Object, lista As Object, listf As Object, i As Long, Wbt As Long, HbT As Long, thetop As Long, leleft, bout, jourr, lig, col, formT
        Dim lefto, ltop
        jourr = Array("lun.", "mar.", "mer.", "jeu.", "ven.", "sam.", "dim.")
        formT = Array("FORMAT", "dd/mm/yyyy", "dd-mm-yyyy", "d/m/yy", "yyyy/mm/dd", "yyyy-mm-dd", "ddd dd mmm yyyy", "dddd dd mmmm yyyy")
        Set fram = uf.Add("Forms.Frame.1", "cal")
         lefto = IIf(uf.Width - (ctr.Left) < large, uf.Width - large - 10, ctr.Left)
            ltop = IIf(uf.Height - ctr.Top < (large / 1.7), (ctr.Top - (ctr.Top - (large / 2))), ctr.Top)
          With fram: .Move lefto, ltop, large, large * 0.7: .BackColor = RGB(80, 80, 80): .BorderStyle = 1: .BorderColor = vbBlue: End With
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 9: .TextAlign = 1: .Move 0, 0, fram.Width / 3, 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            .Value = Format(Date, "mmmm"): .BorderStyle = 1: .ListRows = UBound(formT)
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move listm.Width, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0):
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            .Value = Year(Date): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox choix du format de sortie de la date ***************************************************
        Set listf = fram.Add("Forms.combobox.1", "listeFormat")
        With listf
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move (fram.Width / 3) * 2, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0): .BorderStyle = 1
            .List = formT
            .ListIndex = 0
        End With
        '**********************************************************************************************************************
        ' dimention aux proportions
        Wbt = fram.Width / ((fram.Width / (fram.Width / 3)) * 2.35): HbT = (fram.Height - 41) / 6
        thetop = 20: leleft = fram.Width / (fram.Width / 3)
        For i = 0 To UBound(jourr)    ' ajout de la ligne d'entetes  pour les jours en lettre
            Set bout = fram.Add("Forms.lABEL.1", jourr(i))
            With bout
                .Caption = jourr(i): .Tag = i + 1: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(70, 70, 70): .BorderColor = RGB(0, 200, 255): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(HbT / 2): .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                .Move leleft + (Wbt * i) - 1 * i, thetop, Wbt, Round(fram.Height / 8)
            End With
        Next
        leleft = (fram.Width / (fram.Width / 3))
        thetop = fram.Controls("lun.").Top + fram.Controls("lun.").Height + 2
        i = 0
        For lig = 1 To 6
            For col = 0 To 6
                i = i + 1
                Set bout = fram.Add("Forms.Label.1", "jour" & i)
                With bout
                    .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(255, 255, 255): .ForeColor = RGB(255, 255, 255)
                    .TextAlign = 2: .FontSize = Round(HbT / 2)
                    .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                    .Move leleft + (Wbt * col) - 1 * col, thetop, Wbt, Round(fram.Height / 8)
                    'ajout des liste,frame,userform,textbox dans l'instance(i) de la classe calendrier du label
                    With jr(i): Set .JRS = bout: Set .listeA = lista: Set .listeM = listm: Set .listeF = listf: Set .formm = uf: Set .frame = fram: Set .calendart = uf.Controls("calendar"): End With
                End With
                If col = 6 Or col = 14 Or col = 21 Or col = 28 Or col = 35 Or col = 42 Then thetop = thetop + HbT: leleft = fram.Width / (fram.Width / 3)
            Next col
        Next lig
        fram.Height = fram.Controls("jour42").Top + fram.Controls("jour42").Height + 3
        mise_a_jour fram
    fram.Visible = False
    End Function
    Private Sub JRS_Click()
        If listeF.ListIndex < 1 Then listeF.ListIndex = 1
        If JRS.Caption = "" Then Exit Sub
        If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 150, 0)
        calendart.Value = Format(DateSerial(listeA.Value, listeM.ListIndex + 1, JRS), listeF.Value)
    frame.Visible = False
    End Sub
    Private Sub calendart_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    'formm.Controls("cal").Visible = True
    frame.Visible = True
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then
                frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
                If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            End If
            If JRS.Caption <> "" Then JRS.BackColor = RGB(100, 100, 100): JRS.BorderColor = RGB(0, 200, 255)
            If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 0, 100)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
            If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            frame.Tag = ""
        End If
    End Sub
    Private Sub listeM_Change()
        mise_a_jour listeM.Parent
    End Sub
    Private Sub listeA_Change()
        mise_a_jour listeM.Parent
    End Sub
    Sub mise_a_jour(fram)
        Dim ctrl, i As Long, jj, decal
        For i = 1 To 42: fram.Controls("jour" & i).Caption = "": Next
        decal = Val(fram.Controls(Format(DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, 1), "ddd")).Tag)
        For i = 1 To NB_JOURS(fram.Controls("listemois").ListIndex + 1, fram.Controls("listeAnnée").Value)
            fram.Controls("jour" & i + decal - 1) = i
            If DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, i) = Date Then fram.Controls("jour" & i + decal - 1).ForeColor = vbGreen Else fram.Controls("jour" & i + decal - 1).ForeColor = vbWhite
        Next
    End Sub
    Private Sub calendar_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Me.Controls("cal").Visible = True
    End Sub
    Private Sub formm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    formm.Controls("cal").Visible = False
    End Sub
    Nom : demo2.gif
Affichages : 2910
Taille : 467,0 Ko
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  16. #16
    Expert éminent Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Points : 9 548
    Points
    9 548
    Par défaut
    Re bonjour Patrick,

    C'est dingue les coïncidences, je crée un Usf pour des amis qui viennent de reprendre une petite entreprise, je doute que je puisse intégrer un dtPiker sur leurs PC, et bien, j'en profite pour intégrer ton calendrier et, pour l'instant, tout roule comme sur des roulettes, merci encore, je pense que cette version continuera de me rendre service

    Bonne soirée
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  17. #17
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    re
    bonsoir casefayere je viens de rentrer

    oui tu a vu la dernière version ????
    ben si elle est la c'est pour qu'elle serve au plus grand nombre j'en suis ravi
    en tout ca moi j'ai remplacé tout mes calendars par celle la comme ca plus de soucis si je passe en 64 ou autre raison que se soit
    tu a vu les dernieres nouveautés ?????? "placement relatif c'est bien ca non???
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  18. #18
    Expert éminent Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Points : 9 548
    Points
    9 548
    Par défaut
    re Patrick
    tu a vu les dernieres nouveautés ?????? "placement relatif c'est bien ca non???
    oui, j'ai vu tout ça et après mes derniers essais pour l'adapter à l'usf que j'ai construit, ça fonctionne impeccable, les gens auxquels je vais confier ce fichier ne connaissent rien à excel mais je crois qu'ils vont se friser les moustaches,

    Bonne nuit
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  19. #19
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    bonjours a tous
    si le calendar est très petit on peut avoir des soucis de vue

    pour palier a ce manque
    on ajoute dans la sub mise ajour juste avant le next
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    fram.Controls("jour" & i + decal - 1).ControlTipText = Format(DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, i), "dddd dd mmmm yyyy")
    au passage de la souris sur le bouton le tiptext s'affiche avec la date en grand format

    Nom : demo2.gif
Affichages : 3169
Taille : 79,5 Ko

    code classe :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
     
    '       '******************************** CREATION CONTROL CALENDRIER DYNAMIQUE************************************
    '       '                      Auteur: Chamalin2@hotmail.fr alias patricktoulon sur developpez.com                *
    '       '                                      exemplaire pour DVP.com                                            *
    '       '                                      ----------------------                                             *
    '       ' date de creation : 23/07/2016                                                                           *
    '       ' derniere mise ajour:                                                                                    *
    '       ' 1 aout 2016 : ajout  du placement relatif                                                               *
    '       ' 2 aout 2016 :ajout du tiptext en cas de petite taille du calendrier                                     *
    '       ' licence: libre a condition de citer l'auteur                                                            *
    '       '**********************************************************************************************************
    Option Explicit
    Public WithEvents JRS As MSForms.Label
    Public WithEvents formm As UserForm
    Public WithEvents frame As MSForms.frame
    Public WithEvents calendart As MSForms.TextBox
    Public WithEvents listeA As MSForms.ComboBox
    Public WithEvents listeM As MSForms.ComboBox
    Public WithEvents listeF As MSForms.ComboBox
    Private jr(42) As New calendrier
    Function NB_JOURS(mois, année)
        NB_JOURS = Day(DateSerial(année, mois + 1, 1) - 1)
    End Function
    Function creation_calandrier(uf, ctr, Optional large As Long = 140)
        Dim fram As Object, listm As Object, lista As Object, listf As Object, i As Long, Wbt As Long, HbT As Long, thetop As Long, leleft, bout, jourr, lig, col, formT
        Dim lefto, ltop
        jourr = Array("lun.", "mar.", "mer.", "jeu.", "ven.", "sam.", "dim.")
        formT = Array("FORMAT", "dd/mm/yyyy", "dd-mm-yyyy", "d/m/yy", "yyyy/mm/dd", "yyyy-mm-dd", "ddd dd mmm yyyy", "dddd dd mmmm yyyy")
        Set fram = uf.Add("Forms.Frame.1", "cal")
        lefto = IIf(uf.Width - (ctr.Left) < large, uf.Width - large - 10, ctr.Left)
        ltop = IIf(uf.Height - ctr.Top < large, uf.Height - large * 0.88, ctr.Top)
        With fram: .Move lefto, ltop, large, large * 0.7: .BackColor = RGB(80, 80, 80): .BorderStyle = 1: .BorderColor = vbBlue: End With
        '************************ Ajout de la combobox des mois ********************************
        Set listm = fram.Add("Forms.combobox.1", "listemois")
        With listm
            .ListRows = 12: .Font.Size = 9: .TextAlign = 1: .Move 0, 0, fram.Width / 3, 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0)
            For i = 1 To 12: .AddItem Format("01/0" & i & "/2016", "mmmm"): Next
            .Value = Format(Date, "mmmm"): .BorderStyle = 1: .ListRows = UBound(formT)
        End With
        '*******************************************Ajout de la combobox année***************************************************
        Set lista = fram.Add("Forms.combobox.1", "listeAnnée")
        With lista
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move listm.Width, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0):
            For i = 1800 To Val(Year(Date)) + 50: .AddItem i: Next
            .Value = Year(Date): .BorderStyle = 1
        End With
        '*******************************************Ajout de la combobox choix du format de sortie de la date ***************************************************
        Set listf = fram.Add("Forms.combobox.1", "listeFormat")
        With listf
            .ListRows = 15: .Font.Size = 9: .TextAlign = 1: .Move (fram.Width / 3) * 2, 0, (fram.Width / 3), 15: .BackColor = RGB(150, 150, 150): .ForeColor = RGB(0, 0, 0): .BorderStyle = 1
            .List = formT
            .ListIndex = 0
        End With
        '**********************************************************************************************************************
        ' dimention aux proportions
        Wbt = fram.Width / ((fram.Width / (fram.Width / 3)) * 2.35): HbT = (fram.Height - 41) / 6
        thetop = 20: leleft = fram.Width / (fram.Width / 3)
        For i = 0 To UBound(jourr)    ' ajout de la ligne d'entetes  pour les jours en lettre
            Set bout = fram.Add("Forms.lABEL.1", jourr(i))
            With bout
                .Caption = jourr(i): .Tag = i + 1: .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(70, 70, 70): .BorderColor = RGB(0, 200, 255): .ForeColor = RGB(255, 255, 255)
                .TextAlign = 2: .FontSize = Round(HbT / 2): .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                .Move leleft + (Wbt * i) - 1 * i, thetop, Wbt, Round(fram.Height / 8)
            End With
        Next
        leleft = (fram.Width / (fram.Width / 3))
        thetop = fram.Controls("lun.").Top + fram.Controls("lun.").Height + 2
        i = 0
        For lig = 1 To 6
            For col = 0 To 6
                i = i + 1
                Set bout = fram.Add("Forms.Label.1", "jour" & i)
                With bout
                    .BorderStyle = 1: .BackStyle = 1: .BackColor = RGB(120, 120, 120): .BorderColor = RGB(255, 255, 255): .ForeColor = RGB(255, 255, 255)
                    .TextAlign = 2: .FontSize = Round(HbT / 2)
                    .FontSize = IIf(.FontSize < 7, 7, .FontSize)
                    .Move leleft + (Wbt * col) - 1 * col, thetop, Wbt, Round(fram.Height / 8)
                    'ajout des liste,frame,userform,textbox dans l'instance(i) de la classe calendrier du label
                    With jr(i): Set .JRS = bout: Set .listeA = lista: Set .listeM = listm: Set .listeF = listf: Set .formm = uf: Set .frame = fram: Set .calendart = uf.Controls("calendar"): End With
                End With
                If col = 6 Or col = 14 Or col = 21 Or col = 28 Or col = 35 Or col = 42 Then thetop = thetop + HbT: leleft = fram.Width / (fram.Width / 3)
            Next col
        Next lig
        fram.Height = fram.Controls("jour42").Top + fram.Controls("jour42").Height + 3
        mise_a_jour fram
        fram.Visible = False
    End Function
    Private Sub JRS_Click()
        If listeF.ListIndex < 1 Then listeF.ListIndex = 1
        If JRS.Caption = "" Then Exit Sub
        If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 150, 0)
        calendart.Value = Format(DateSerial(listeA.Value, listeM.ListIndex + 1, JRS), listeF.Value)
        frame.Visible = False
    End Sub
    Private Sub calendart_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    'formm.Controls("cal").Visible = True
        frame.Visible = True
    End Sub
    Private Sub JRS_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If JRS.BackColor = RGB(120, 120, 120) Then
            If frame.Tag <> "" Then
                frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
                If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            End If
            If JRS.Caption <> "" Then JRS.BackColor = RGB(100, 100, 100): JRS.BorderColor = RGB(0, 200, 255)
            If JRS.ForeColor <> vbGreen Then JRS.ForeColor = RGB(255, 0, 100)
            JRS.Parent.Tag = JRS.Name
        End If
    End Sub
    Private Sub frame_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If frame.Tag <> "" Then
            frame.Controls(frame.Tag).BackColor = RGB(120, 120, 120): frame.Controls(frame.Tag).BorderColor = vbWhite
            If frame.Controls(frame.Tag).ForeColor <> vbGreen Then frame.Controls(frame.Tag).ForeColor = vbWhite
            frame.Tag = ""
        End If
    End Sub
    Private Sub listeM_Change()
        mise_a_jour listeM.Parent
    End Sub
    Private Sub listeA_Change()
        mise_a_jour listeM.Parent
    End Sub
    Sub mise_a_jour(fram)
        Dim ctrl, i As Long, jj, decal
        For i = 1 To 42: fram.Controls("jour" & i).Caption = "": Next
        decal = Val(fram.Controls(Format(DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, 1), "ddd")).Tag)
        For i = 1 To NB_JOURS(fram.Controls("listemois").ListIndex + 1, fram.Controls("listeAnnée").Value)
            fram.Controls("jour" & i + decal - 1) = i
            If DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, i) = Date Then fram.Controls("jour" & i + decal - 1).ForeColor = vbGreen Else fram.Controls("jour" & i + decal - 1).ForeColor = vbWhite
            fram.Controls("jour" & i + decal - 1).ControlTipText = Format(DateSerial(fram.Controls("listeAnnée").Value, fram.Controls("listemois").ListIndex + 1, i), "dddd dd mmmm yyyy")
        Next
    End Sub
    Private Sub calendar_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        Me.Controls("cal").Visible = True
    End Sub
    Private Sub formm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        formm.Controls("cal").Visible = False
    End Sub
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  20. #20
    Nouveau membre du Club
    Homme Profil pro
    Retraite
    Inscrit en
    Août 2016
    Messages
    38
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Belgique

    Informations professionnelles :
    Activité : Retraite

    Informations forums :
    Inscription : Août 2016
    Messages : 38
    Points : 29
    Points
    29
    Par défaut oups je suis un peux perdu
    bonjour a tous je viens de parcourir cette discussion mais je suis perdu,
    ma question vas peut etre vous paraitre stupide, mais je pense que c'est ce que je recherche pour remplacer 23 dtpicker dans un de mes fichier, mais je ne comprend pas comment je peu l'utiliser, sur plusieurs zone date et surtout comment récupérer la date introduite dans le calendrier afin de pouvoir la transférer vers le fichier?


    Nom : Capture5.JPG
Affichages : 2705
Taille : 99,0 Ko


    pour l'instant j'utilise le code suivant a partir des dtpicker. ce qui pose problème lors de l'ouverture sur d'autre ordi
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
     
    Private Sub DebutExam1_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
     
    End Sub
     
        Private Sub UserForm_Initialize()
     
        Info1.Visible = False
     
        ' periodes examens
     
             Me.DebutExam1 = ActiveWorkbook.Sheets("decembre-1").Range("m11").Value
             Me.DebutExam2 = ActiveWorkbook.Sheets("juin").Range("m11").Value
             Me.DebutExam3 = ActiveWorkbook.Sheets("decembre").Range("m11").Value
             Me.Finexam1 = ActiveWorkbook.Sheets("decembre-1").Range("m11").Value
             Me.Finexam2 = ActiveWorkbook.Sheets("juin").Range("m11").Value
             Me.Finexam3 = ActiveWorkbook.Sheets("decembre").Range("m11").Value
     
     
     
        ' periodes Non Scolaire
     
        ' debut
            Me.debSco1 = ActiveWorkbook.Sheets("decembre-1").Range("m11").Value
            Me.debSco2 = ActiveWorkbook.Sheets("Fevrier").Range("m11").Value
            Me.debSco3 = ActiveWorkbook.Sheets("Planning").Range("c2").Value
            Me.debSco4 = ActiveWorkbook.Sheets("ferier").Range("a6").Value
            Me.debSco5 = ActiveWorkbook.Sheets("juillet").Range("m11").Value
            Me.debSco6 = ActiveWorkbook.Sheets("novembre").Range("m11").Value
            Me.debSco7 = ActiveWorkbook.Sheets("decembre").Range("m11").Value
            Me.FeteFWB = ActiveWorkbook.Sheets("ferier").Range("a20").Value
     
     
        'autre debut
     
     
     
            Me.debSco9 = ActiveWorkbook.Sheets("Planning").Range("c20").Value
     
            Me.debSco10 = ActiveWorkbook.Sheets("Planning").Range("c21").Value
     
     
     
        'fin
            Me.FinSco1 = ActiveWorkbook.Sheets("janvier").Range("m11").Value
            Me.FinSco2 = ActiveWorkbook.Sheets("Fevrier").Range("m11").Value
            Me.FinSco3 = ActiveWorkbook.Sheets("Planning").Range("c2").Value
            Me.FinSco4 = ActiveWorkbook.Sheets("ferier").Range("a6").Value
            Me.FinSco5 = ActiveWorkbook.Sheets("Aout").Range("m11").Value
            Me.FinSco6 = ActiveWorkbook.Sheets("novembre").Range("m11").Value
            Me.FinSco7 = ActiveWorkbook.Sheets("janvier+1").Range("m11").Value
     
        'autre fin
     
     
     
            Me.FinSco9 = ActiveWorkbook.Sheets("Planning").Range("d20").Value
     
            Me.FinSco10 = ActiveWorkbook.Sheets("Planning").Range("d21").Value
     
        End Sub
     
     
     
     
     
     
    Private Sub Valider_Click()
     
     Sheets("Planning").Select
      ActiveSheet.Unprotect "wappy"
     
     ' Periodes examens
     ' debut
     
     Range("c6") = DebutExam1.Value
     Range("c7") = DebutExam2.Value
     Range("c8") = DebutExam3.Value
     
     ' fin
     
     
     Range("d6") = Finexam1.Value
     Range("d7") = Finexam2.Value
     Range("d8") = Finexam3.Value
     
     ' periodes Non Scolaire
     
     ' debut
        Range("c12") = debSco1.Value
         Range("c13") = debSco2.Value
          Range("c14") = debSco3.Value
           Range("c15") = debSco4.Value
            Range("c16") = debSco5.Value
             Range("c18") = debSco6.Value
              Range("c19") = debSco7.Value
                Range("c17") = FeteFWB.Value
     
     
     
     
                    If debSco9.Value = "" Then
                    Range("c20") = ""
                    Else: Range("c20") = CDate(debSco9.Value)
                    End If
     
                        If debSco10.Value = "" Then
                        Range("c21") = ""
                        Else: Range("c21") = CDate(debSco10.Value)
                        End If
     
     
        'fin
     
        Range("d12") = FinSco1.Value
          Range("d13") = FinSco2.Value
           Range("d14") = FinSco3.Value
            Range("d15") = FinSco4.Value
             Range("d16") = FinSco5.Value
              Range("d18") = FinSco6.Value
               Range("d19") = FinSco7.Value
     
     
     
                    If FinSco9.Value = "" Then
                    Range("d20") = ""
                    Else: Range("d20") = CDate(FinSco9.Value)
                    End If
     
                        If FinSco10.Value = "" Then
                        Range("d21") = ""
                        Else: Range("d21") = CDate(FinSco10.Value)
                        End If
     
     
     
        Unload Me
     
      Sheets("Planning").Protect "wappy"
        'Unload ferme l'UserForm
        'Le nom de l'UserForm a été remplacé par Me (puisque ce code est placé dans l'UserForm à fermer
     
    End Sub
    Private Sub AutrePer1_Click()
     Call teste1
     
    End Sub
     
    Sub teste1()
     
    If AutrePer1.Value = True Then
    debSco9.Visible = True
    FinSco9.Visible = True
    AutrePer2.Visible = True
    Else
    debSco9.Visible = False
    FinSco9.Visible = False
    AutrePer2.Value = False
    AutrePer2.Visible = False
    End If
    End Sub
     
    Private Sub AutrePer2_Click()
    Call teste2
     
    End Sub
     
    Sub teste2()
     
    If AutrePer2.Value = True Then
    debSco10.Visible = True
    FinSco10.Visible = True
     
    Else
    debSco10.Visible = False
    FinSco10.Visible = False
     
    End If
    End Sub
     
     
     
     
     
    Private Sub debSco9_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Info1.Visible = False And debSco9.Value = "" Then
            Info1.Visible = True 'Label visible
     
    ElseIf IsDate(debSco9.Value) Then 'SI valeur date
            Info1.Visible = False 'Label masqué
     
    Else 'SINON ...
                Info1.Visible = False 'Label masqué
    End If
     
     
    End Sub
    Private Sub debSco9_Change()
     
    If IsDate(debSco9.Value) Then 'SI valeur date
            Info1.Visible = False 'Label visble
     
    Else 'SINON ...
                Info1.Visible = True 'Label masqué
    End If
    End Sub
     
     
    Private Sub debSco10_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Info1.Visible = False And debSco10.Value = "" Then
            Info1.Visible = True 'Label visible
     
    ElseIf IsDate(debSco10.Value) Then 'SI valeur date
            Info1.Visible = False 'Label masqué
     
    Else 'SINON ...
                Info1.Visible = False 'Label masqué
    End If
     
    End Sub
     
     
     
    Private Sub FinSco9_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Info1.Visible = False And FinSco9.Value = "" Then
            Info1.Visible = True 'Label visible
     
    ElseIf IsDate(FinSco9.Value) Then 'SI valeur date
            Info1.Visible = False 'Label masqué
     
    Else 'SINON ...
                Info1.Visible = False 'Label masqué
    End If
     
    End Sub
     
    Private Sub FinSco10_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Info1.Visible = False And FinSco10.Value = "" Then
            Info1.Visible = True 'Label visible
     
    ElseIf IsDate(FinSco10.Value) Then 'SI valeur date
            Info1.Visible = False 'Label masqué
     
    Else 'SINON ...
                Info1.Visible = False 'Label masqué
    End If
     
    End Sub
    encore merci d'avance pour votre aide.
    ps je suis débutant et autodidacte enfin avec votre aide

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 5 12345 DernièreDernière

Discussions similaires

  1. [Logiciel] Même calendrier pour tous.
    Par _MAID dans le forum Apple
    Réponses: 4
    Dernier message: 24/01/2011, 19h02
  2. Réponses: 2
    Dernier message: 07/07/2007, 00h02
  3. [Calendar] Traduction du contrôle calendrier
    Par crimsonPhantom dans le forum ASP.NET
    Réponses: 5
    Dernier message: 12/03/2006, 13h46
  4. TEdit numérique pour tous les claviers
    Par totofweb dans le forum C++Builder
    Réponses: 2
    Dernier message: 10/06/2004, 11h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo