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

VB.NET Discussion :

Problème avec DateTimePicker


Sujet :

VB.NET

  1. #1
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 6
    Points : 3
    Points
    3
    Par défaut Problème avec DateTimePicker
    Bonjour à tous,

    j'ai un problème avec DateTimepicker.

    Quand je fixe une nouvelle valeur, aucuns soucis, je suis positionné sur la bonne date. Par contre quand je cherche à extraire les infos (jour de la semaine, mois ..etc) plus rien ne fonctionne. Je pense que c'est un pb trivial, mais je galère un max.

    Cordialement.

    BYS

  2. #2
    Inactif  

    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2012
    Messages
    4 904
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2012
    Messages : 4 904
    Points : 10 168
    Points
    10 168
    Billets dans le blog
    36
    Par défaut
    Bonjour,

    Sans voir ton code, impossible de voir ce qui ne va pas. Pour peu que je me souvienne la valeur du contrôle est de type DateTime. En gros, tu devrais trouver tout ce dont tu as besoin avec la classe DateTime (pour des données ponctuelles) et/ou la structure TimeSpan() (pour des calculs d'intervalles). De toutes façons, tu ne perds rien à afficher ton code.
    À ma connaissance, le seul personnage qui a été diagnostiqué comme étant allergique au mot effort. c'est Gaston Lagaffe.

    Ô Saint Excel, Grand Dieu de l'Inutile.

    Excel n'a jamais été, n'est pas et ne sera jamais un SGBD, c'est pour cela que Excel s'appelle Excel et ne s'appelle pas Access junior.

  3. #3
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 6
    Points : 3
    Points
    3
    Par défaut
    Bon,
    a priori, c'est résolu.

    J'ai surement un pb dans mon code.

    Car j'ai juste rajouté une valeur string.

    Comme celà fonctionne et que je n'ai pas terminé de faire mon agenda à ma manière, je continue.
    Je vous donnerais peut-être la solution a mon pb après.

    Cordialement.
    BYS

  4. #4
    Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 6
    Points : 3
    Points
    3
    Par défaut fusion + Balise CODE
    Bonjour,

    visiblement j'ai un gros pb.

    Ce n'est pas aléatoire, mais quand je rajoute du code, le problème change (des instructions qui fonctionnaient avant, terminé).

    Comme j'utilise des tableaux, il faut que je regarde dans ce sens (il est possible qu'un dépassement de capacité est a voir avec mon pb).

    Je rajoute mon code. Si quelqu'un voit quelque chose, merci

    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
    Imports System.Text.RegularExpressions
    Imports System.IO
    Imports System.Math
    Public Class Planning1
        Public Property FirstDisplayedScrollingRowIndex As Integer
     
        Public an As Integer = System.DateTime.Now.Year
        Dim tjour As Integer = System.DateTime.Now.Day
        Dim tmois As Integer = System.DateTime.Now.Month
        Dim tan As Integer = System.DateTime.Now.Year
     
        Dim curseur As Integer = 0
        Public Anneeb(12, 31, 10) As String
        Public semaine(7)
        Public moisc As Integer = System.DateTime.Now.Month
        Public mois(12) As Integer
        Public moisn(12) As String
        Dim couleur As Color = Color.Bisque
        Dim Anneecourante As Integer = 2013
        Dim moiscourant As Integer = 11
        Dim jourcourant As Integer = System.DateTime.Now.Day
        Dim datetext As String = jourcourant & "/" & moiscourant & "/" & Anneecourante
     
        Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
     
        End Sub
     
        Private Sub Planning1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
     
            Dim dte As String = DateTimePicker1.Value
            mois(1) = 31
            mois(2) = 28
            mois(3) = 31
            mois(4) = 30
            mois(5) = 31
            mois(6) = 30
            mois(7) = 31
            mois(8) = 31
            mois(9) = 30
            mois(10) = 31
            mois(11) = 30
            mois(12) = 31
            moisn(1) = "janvier"
            moisn(2) = "fevrier"
            moisn(3) = "mars"
            moisn(4) = "avril"
            moisn(5) = "mai"
            moisn(6) = "juin"
            moisn(7) = "juillet"
            moisn(8) = "aout"
            moisn(9) = "septembre"
            moisn(10) = "octobre"
            moisn(11) = "novembre"
            moisn(12) = "decembre"
            semaine(1) = "dimanche"
            semaine(2) = "lundi"
            semaine(3) = "mardi"
            semaine(4) = "mercredi"
            semaine(5) = "jeudi"
            semaine(6) = "vendredi"
            semaine(7) = "samedi"
            charge_annee()
            charge_trimestre()
            charge_mois()
     
        End Sub
        Private Sub charge_annee()
            DataGridView1.Rows.Clear()
     
            Dim i As Integer = 0
            Dim lig(31, 13) As String
            Dim lige(13)
            Dim dte As Date
            Dim jj1 As Integer = 1
            Dim jj2 As Integer = 1
            Dim jj3 As Integer = 1
            Dim jj4 As Integer = 1
            annee.Text = DatePart("yyyy", DateTimePicker1.Value)
            DateTimePicker1.Value = datetext
     
            For jj1 = 1 To 12
                For jj2 = 1 To mois(jj1)
                    dte = jj2 & "/" & jj1 & "/" & DatePart("yyyy", DateTimePicker1.Value)
                    Anneeb(jj1, jj2, 1) = semaine(DatePart("w", dte))
                    Anneeb(jj1, jj2, 2) = DatePart(DateInterval.WeekOfYear, dte)
                    Anneeb(jj1, jj2, 3) = dte
     
                Next
            Next
            For jj2 = 1 To 31
                Array.Clear(lige, 0, 13)
                lige(0) = jj2
                For jj1 = 1 To 12
                    lige(jj1) = Anneeb(jj1, jj2, 1)
                Next
                If i = 0 Then
                    couleur = Color.Cyan
                    i = 1
                Else
                    couleur = Color.LightCoral
                    i = 0
                End If
     
                With Me.DataGridView1.RowTemplate
     
                    .DefaultCellStyle.BackColor = couleur
                    .Height = 35
                    .MinimumHeight = 20
                End With
                If jj2 = DatePart("d", DateTimePicker1.Value) Then
     
                    curseur = jj2 - 1
                End If
                jj4 = jj4 + 1
                DataGridView1.Rows.Add(lige)
                '          MsgBox(lige(1) & " " & jj2)
            Next
            MsgBox(jj4)
            DataGridView1.FirstDisplayedScrollingRowIndex = curseur
            DataGridView1.Rows(curseur).Cells(DatePart("m", DateTimePicker1.Value)).Selected = True
        End Sub
        Private Sub charge_trimestre()
            DataGridView2.Rows.Clear()
            Dim i As Integer = 0
            Dim lig(31, 4) As String
            Dim lige(3)
            Dim ligm(3)
            Dim dte As String = ""
            dte = DateTimePicker1.Value
            trimestre.Text = (" trimestre " & DatePart("q", dte) & " " & (DatePart("yyyy", dte)))
            Dim jj1 As Integer = ((DatePart("q", dte) - 1) * 3) + 1
            Dim jj2 As Integer = (DatePart("q", dte) * 3)
            Dim jj3 As Integer = 1
            Dim jj4 As Integer = 1
            dte = jj2 & "/" & DatePart("m", DateTimePicker1.Value) & "/" & DatePart("yyyy", DateTimePicker1.Value)
            While jj4 <= 3
                lige(jj4) = moisn(jj1)
                ligm(jj4) = jj1
                DataGridView2.Columns(jj4).HeaderText = moisn(jj1)
                jj1 = jj1 + 1
                jj4 = jj4 + 1
            End While
     
            For jj2 = 1 To 31
                Array.Clear(lige, 0, 3)
                lige(0) = jj2
                For jj1 = 1 To 3
                    lige(jj1) = Anneeb(ligm(jj1), jj2, 1)
                Next
                If i = 0 Then
                    couleur = Color.Cyan
                    i = 1
                Else
                    couleur = Color.LightCoral
                    i = 0
                End If
     
                With Me.DataGridView2.RowTemplate
     
                    .DefaultCellStyle.BackColor = couleur
                    .Height = 35
                    .MinimumHeight = 20
                End With
                DataGridView2.Rows.Add(lige)
            Next
     
            DataGridView2.FirstDisplayedScrollingRowIndex = curseur
        End Sub
        Private Sub charge_mois()
            DataGridView3.Rows.Clear()
            Dim moiscourant As Integer
            Dim i As Integer = 0
            Dim lige(13)
            Dim dte As String = ""
            Dim jj1 As Integer = 1
            Dim jj2 As Integer = 1
            Dim jj3 As Integer = 1
            moiscourant = DatePart("m", DateTimePicker1.Value)
            For jj1 = 1 To mois(moiscourant)
                lige(0) = jj1
                lige(1) = Anneeb(moiscourant, jj1, 1)
                lige(2) = Anneeb(moiscourant, jj1, 2)
                If i = 0 Then
                    couleur = Color.Cyan
                    i = 1
                Else
                    couleur = Color.LightCoral
                    i = 0
                End If
     
                With Me.DataGridView3.RowTemplate
     
                    .DefaultCellStyle.BackColor = couleur
                    .Height = 35
                    .MinimumHeight = 20
                End With
                DataGridView3.Rows.Add(lige)
            Next
            DataGridView3.FirstDisplayedScrollingRowIndex = curseur
        End Sub
        Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
            datetext = DateTimePicker1.Value
            DataGridView1.Rows.Clear()
            charge_annee()
            charge_trimestre()
            charge_mois()
        End Sub
     
        Private Sub DataGridView2_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellContentClick
        End Sub
     
        Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
            DataGridView1.Rows.Clear()
     
            datetext = Anneeb(DataGridView1.CurrentCell.ColumnIndex, (DataGridView1.CurrentCell.RowIndex + 1), 3)
            MsgBox(Anneeb(DataGridView1.CurrentCell.ColumnIndex, (DataGridView1.CurrentCell.RowIndex + 1), 3))
            charge_annee()
            charge_trimestre()
            charge_mois()
        End Sub
     
        Private Sub boutonannee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles boutonanneemoins.Click
            DataGridView1.Rows.Clear()
            tan = tan - 1
            tjour = 1
            tmois = 1
            datetext = tjour & "/" & tmois & "/" & tan
            charge_annee()
            charge_trimestre()
            charge_mois()
        End Sub
     
        Private Sub boutonanneeplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles boutonanneeplus.Click
            DataGridView1.Rows.Clear()
            tan = tan + 1
            tjour = 1
            tmois = 1
            datetext = tjour & "/" & tmois & "/" & tan
            charge_annee()
            charge_trimestre()
            charge_mois()
        End Sub
    End Class

    Cordialement.

    BYS

  5. #5
    Membre chevronné Avatar de _Ez3kiel
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2013
    Messages
    836
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Janvier 2013
    Messages : 836
    Points : 1 961
    Points
    1 961
    Par défaut
    visiblement j'ai un gros pb. [...] Je rajoute mon code. Si quelqu'un voit quelque chose, merci
    Loin de moi la paresse de décortiquer ton code, mais si tu pouvais être plus précis que "J'ai un gros pb", histoire de nous aiguiller et nous éviter une migraine peut-être inutile. (Genre le message de l'exception, la ligne pointée, un exemple de la finalité de ton appli, tout ça tout ça ...)
    Aider les autres, c'est encore la meilleure façon de s'aider soi-même. Martin Gray

    ToDo : Faire une ToDo List

  6. #6
    Membre expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Points : 3 304
    Points
    3 304
    Par défaut
    Comme celà fonctionne et que je n'ai pas terminé de faire mon agenda à ma manière, je continue.
    Je vous donnerais peut-être la solution a mon pb après.
    Perso ce message me déplait un peu, sur un forum d'entraide je trouve que si on solutionne son problème soi-même c'est bien de prendre le temps que d'autres auraient pris pour t'aider pour donner la solution
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

Discussions similaires

  1. problème avec DateTimePicker
    Par lepeule dans le forum Bases de données
    Réponses: 6
    Dernier message: 05/07/2010, 11h41
  2. Problème avec un datetimepicker et l'évènement Valuechanged
    Par Machine Head dans le forum Windows Forms
    Réponses: 0
    Dernier message: 24/08/2009, 17h46
  3. Problème avec le type 'Corba::Any_out'
    Par Steven dans le forum CORBA
    Réponses: 2
    Dernier message: 14/07/2002, 18h48
  4. Problème avec la mémoire virtuelle
    Par Anonymous dans le forum CORBA
    Réponses: 13
    Dernier message: 16/04/2002, 16h10

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