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 :

plantage application (code programme ?)


Sujet :

VB.NET

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Âge : 55
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Par défaut plantage application (code programme ?)
    Bonjour a tous,

    j'ai fait une petite application qui fonctionne bien sur 12 postes, mais bien entendu sur le 13ème ça plante...

    j'ai le fichier d'erreur, mais je ne sais pas l'interpréter ou comment activer le JIT.

    pourriez-vous m'aider à trouver l'erreur du code programme.

    ************** Texte de l'exception **************
    System.Runtime.InteropServices.COMException (0x8002000B): Index non valide. (Exception de HRESULT : 0x8002000B (DISP_E_BADINDEX))
    à Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
    à Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
    à gestion_hotline.hotline.Button8_Click(Object sender, EventArgs e)
    à System.Windows.Forms.Control.OnClick(EventArgs e)
    à System.Windows.Forms.Button.OnClick(EventArgs e)
    à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    à System.Windows.Forms.Control.WndProc(Message& m)
    à System.Windows.Forms.ButtonBase.WndProc(Message& m)
    à System.Windows.Forms.Button.WndProc(Message& m)
    à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Assemblys chargés **************
    mscorlib
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3082 (QFE.050727-3000)
    CodeBase : file:///c:/WINDOWS/Microsoft.NET/Fra...7/mscorlib.dll
    ----------------------------------------
    COAXEL Services V2.1
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.0.0
    CodeBase : file:///C:/Documents%20and%20Setting...ces%20V2.1.exe
    ----------------------------------------
    Microsoft.VisualBasic
    Version de l'assembly : 8.0.0.0
    Version Win32 : 8.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...isualBasic.dll
    ----------------------------------------
    System
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
    ----------------------------------------
    System.Windows.Forms
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...dows.Forms.dll
    ----------------------------------------
    System.Drawing
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...em.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...e.Remoting.dll
    ----------------------------------------
    System.Configuration
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...figuration.dll
    ----------------------------------------
    System.Xml
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3082 (QFE.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL...System.Xml.dll
    ----------------------------------------
    mscorlib.resources
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3082 (QFE.050727-3000)
    CodeBase : file:///c:/WINDOWS/Microsoft.NET/Fra...7/mscorlib.dll
    ----------------------------------------
    System.Windows.Forms.resources
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase : file:///C:/WINDOWS/assembly/GAC_MSIL....resources.dll
    ----------------------------------------
    ************** Débogage JIT **************
    Pour activer le débogage juste-à-temps (JIT), le fichier de configuration pour cette
    application ou cet ordinateur (machine.config) doit avoir la valeur
    jitDebugging définie dans la section system.windows.forms.
    L'application doit également être compilée avec le débogage
    activé.
    Par exemple :
    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>
    Lorsque le débogage juste-à-temps est activé, les exceptions non gérées
    seront envoyées au débogueur JIT inscrit sur l'ordinateur
    plutôt que d'être gérées par cette boîte de dialogue.
    Merci d'avance.

  2. #2
    Membre Expert Avatar de Danyel
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2005
    Messages
    1 699
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juillet 2005
    Messages : 1 699
    Par défaut
    Comme signale sur la premiere ligne
    Index non valide
    Donc un de tes index ne doit pas etre bien gere

  3. #3
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    il faut mettre des try catch partout
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 57
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    Citation Envoyé par Pol63
    il faut mettre des try catch partout
    Pour ma part je n'en mets quasiment jamais, sauf bien entendu où cela est strictement nécessaire. Si le programme est bien pensé et s'il on utilise la technologie objet comme il faut le try catch ne devrait pas s'imposer.
    Bon c'est peut-être un réflexe de vieux pour qui toutes ces facilités actuelles n'existaient pas quand il a commencé.

    Pour la question initiale il y a effectivement une liaison tardive qui m**de.
    Et si tu nous donne le message d'erreur et pas le code ça va être un peu "boule de cristal".

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Âge : 55
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Par défaut
    Merci pour la piste de recherche.

    donc effectivement je fais des liaison tardive, car j'utilise des commande pour manipuler excel.
    j'ai bien questionner pour savoir comment éliminer ces liaison tardive, mais plusieurs confirmé m'on dit "pas le choix,tu peux pas faire autrement".

    Néanmoins pourquoi cela fonctionne sur 12 poste et pas sur le 13ème poste ??

    si vous avez besoin du code, je vais le mettre. Mais soyez indulgent car je sais qu'il est un peu bordélique.

    a demain pour le code

  6. #6
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    Citation Envoyé par Geo2A Voir le message
    Pour ma part je n'en mets quasiment jamais, sauf bien entendu où cela est strictement nécessaire. Si le programme est bien pensé et s'il on utilise la technologie objet comme il faut le try catch ne devrait pas s'imposer.

    pour ma part j'en mets dans tous les endroits où j'ai du code, déjà un développeur qui ne fait pas de bug ca n'existe pas, et puis il y a moult choses qui peuvent générer une exception ...

    de plus on ne sait jamais ce qui peut arriver, j'ai déjà vu des exception dans les classes graphiques qui se produise très rarement, et que l'appli plante devant un client c'est pas top

    sans parler qu'un .abort sur un thread déclenche une exception qui se propage, et qui peut se produire dans le framework

    l'impact sur les performances est négligeable
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  7. #7
    Membre Expert Avatar de Danyel
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2005
    Messages
    1 699
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juillet 2005
    Messages : 1 699
    Par défaut
    Citation Envoyé par Geo2A Voir le message
    Pour ma part je n'en mets quasiment jamais
    Sans vouloir en rajouter une couche inutile, c'est vraiment la derniere des choses a ne pas faire ...
    Sans rentrer dans les details, moi je me suis cree une gestion des erreurs perso qui controle automatiquement TOUT le code (un peu à la maniere de l'ancien ON ERROR GOTO) et je rajoute encore des try/catch ciblés.
    C'est comme si vous achetez une voiture avec 12 vitesses, et que vous n'en utilisiez que 3 !!!

  8. #8
    Membre très actif Avatar de Sacha999
    Inscrit en
    Mars 2007
    Messages
    294
    Détails du profil
    Informations personnelles :
    Âge : 46

    Informations forums :
    Inscription : Mars 2007
    Messages : 294
    Par défaut
    Tu n'as pas la bonne version d'Excel sur le 13 eme poste (je dis au pif )

  9. #9
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 57
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    Sans vouloir en rajouter une couche inutile, c'est vraiment la derniere des choses a ne pas faire ...
    Ce n'est pas une couche inutile, et les arguments de Pol63 je les écoute aussi.
    Partager avec d'autres développeur c'est important et formateur.
    C'est donc un aspect que je vais intégrer à l'avenir dans mes dev.

    Ceci dit comme je l'ai écrit plus haut j'en mets tout de même là où c'est strictement nécessaire par opposition à "partout". Je vais me forcer à en mettre un peu plus !

  10. #10
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    donne nous des exemples où c'est pas nécessaire, parce que il n'y en a pas des masses je pense, meme un calcul tu peux tomber sur une division par zéro
    quand une appli évolue dans le temps, certaines parties de code peuvent alors impactées par une modif à un tout autre endroit ...
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  11. #11
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 57
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    Ben justement c'est l'exemple type de la division par zéro.
    Quand je fais une division je teste toujours le diviseur avec un si égale zéro alors.
    Car d'une manière générale si le diviseur est à zéro cela doit me remonter une alerte pour le code appelant.
    Mais comme tu le soulignais dans ton message précédent peut-être que le try catch est plus efficace en terme de rapidité que le if then.

  12. #12
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    non là dessus tu as raison, un if est quand même le mieux, plus performant et qui oblige à se poser la question de "qu'est ce que je fais si ca vaut zéro" plutot que de voir après coup dans un rapport que ca peut valoir zéro
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  13. #13
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    291
    Détails du profil
    Informations personnelles :
    Âge : 57
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 291
    Par défaut
    Bonjour,

    Voilà l'avantage de l'échange sur un forum, on se comprend mieux.

    Pour ma part une des grosse avancée de .NET au niveau de la MSDN c'est les commentaires pour écrire du "safe code", la liste des erreurs susceptibles de se produire, permet justement de faire un branchement conditionnel et de mettre l'objet dans un état d'erreur approprié, ce qui permet d'encapsuler le problème au niveau de la classe et de configurer les échanges entre objets en fonction.

    C'est en cela que je n'utilise pas le try catch mais plutôt le if then lorsqu'il s'agit d'une erreur connue. Bien évidement pour certaines opérations comme celle utilisant l'espace de nom drawing, elles sont plus risquées (comme tu l'as précédemment souligné) donc là le try catch devient impératif.

    Ceci dit on attend toujours le code de celui qui a posé la question ....

  14. #14
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Âge : 55
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Par défaut
    bonjour a tous,

    ci-dessous le code du bouton qui déclenche l'erreur sur le 13éme poste.
    Nota: c'est après l'envoi du mail, donc au moment quelque part à la construction de l'enregistrement des données dans le fichier excel.

    Merci de votre aide.

    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
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            ' enregister et envoyé
            Dim oExcel As Object
            Dim oBook As Object
            Dim oSheet As Object
            Dim nom_fichier As String
            Dim madate = CStr(Date.Today)
            Dim fichierexiste
            Dim i
            Dim xlUp = 0
            Dim numhot As Integer
            madate = Replace(madate, "/", "-")
            madate = Mid(madate, 4)
            nom_fichier = ("c:\hotline\" & madate & " " & mesinfos.TextBox2.Text)
            fichierexiste = My.Computer.FileSystem.FileExists("c:\hotline\" & madate & " " & mesinfos.TextBox2.Text & ".xls")
     
            'contole de format des données
     
            If mesinfos.TextBox2.Text = "" Then
                info.Text = "Veuillez remplir le champs ITC dans mes infos."
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If ComboBox4.Text = "" Or ComboBox4.Text = "Temps Passée" Then
                info.Text = "Veuillez sélectionner un TEMPS"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If ComboBox2.SelectedIndex = 0 Then
                info.Text = "Veuillez sélectionner un Département"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If TextBox1.Text = "" Then
                info.Text = "Veuillez remplir le champs Société"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If TextBox2.Text = "" Then
                info.Text = "Veuillez remplir le champs Contact"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If IsNumeric(TextBox7.Text) = False Then
                info.Text = "un Code Agence est composé de chiffres !"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If IsNumeric(TextBox4.Text) = False Then
                info.Text = "un Compte SOON est composé de chiffres !"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If ComboBox3.SelectedIndex = 0 Then
                info.Text = "Veuillez sélectionner une Famille Produit"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If TextBox3.Text = "" Then
                info.Text = "Veuillez remplir le champs Demandeur hotline"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If TextBox6.Text = "" Then
                info.Text = "Veuillez remplir le champs Questions"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If TextBox8.Text = "" Then
                info.Text = "Veuillez remplir le champs Réponses"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If CheckBox1.Checked = True Then
                If TextBox9.Text = "" And CheckBox1.Checked = True Then
                    info.Text = "l'adresse mail Demandeur est invalide..."
                    System.Windows.Forms.Application.DoEvents()
                    Exit Sub
                End If
            End If
            If mesinfos.TextBox5.Text = "" And CheckBox1.Checked = True Then
                info.Text = "l'adresse mail ITC est invalide..."
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
     
            If CheckBox1.Checked = True Then
                If TextBox9.Text Like "?*@?*.??*" Then
                Else
                    info.Text = "l'adresse mail du demandeur est invalide !"
                    System.Windows.Forms.Application.DoEvents()
                    Exit Sub
                End If
                If nbrcaractere.NbOc(TextBox9.Text, "@", False) > 1 Then
                    info.Text = "l'adresse mail du demandeur est invalide !"
                    System.Windows.Forms.Application.DoEvents()
                    Exit Sub
                End If
            End If
     
            If mesinfos.TextBox12.Text = "" And CheckBox1.Checked = True Then
                info.Text = "User invalide...Voir dans mes infos !"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If mesinfos.TextBox11.Text = "" And CheckBox1.Checked = True Then
                info.Text = "Password invalide...Voir dans mes infos !"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
            If mesinfos.TextBox13.Text = "" And CheckBox1.Checked = True Then
                info.Text = "SMTP invalide...Voir dans mes infos !"
                System.Windows.Forms.Application.DoEvents()
                Exit Sub
            End If
     
            'enregistrement des données
            If fichierexiste Then
                If CheckBox1.Checked = True Then
                    testconnexion.testconnexion()
                    If testok = True Then
                        If CheckBox3.Checked = False Then
                            principal.destinatairemail = TextBox9.Text
                        Else
                            principal.destinatairemail = TextBox9.Text & ";" & mesinfos.TextBox5.Text
                        End If
     
                        principal.entetemail = "réponse de votre demande de hotline"
                        principal.messagemail = "Bonjour," & vbLf & vbLf & "Veuillez trouver ci-dessous notre réponse :" & vbLf & vbLf & "ITC de Hotline :  " & (mesinfos.TextBox2.Text) & vbLf & vbLf & "Date :  " & (DateTimePicker1.Text) & vbLf & vbLf & "Client :  " & (TextBox1.Text) & vbLf & vbLf & "Contact :  " & (TextBox2.Text) & vbLf & vbLf & "TEL :  " & (TextBox14.Text) & vbLf & vbLf & "Code Soon :  " & (TextBox4.Text) & vbLf & vbLf & "Question :  " & vbLf & (TextBox6.Text) & vbLf & vbLf & "Réponse :  " & vbLf & (TextBox8.Text) & vbLf & vbLf & "Action Commerciale à mener :  " & (TextBox10.Text) & vbLf & vbLf & "Temps Passée :  " & (ComboBox4.Text) & " .Minutes" & vbLf & vbLf & vbLf & "Vous en Souhaitant Bonne Réception." & vbLf & "Cordialement." & vbLf & vbLf & (mesinfos.TextBox2.Text)
                        principal.piecejointemail = Label11.Text
                        envoimail.envoimail()
                        If mailok = True Then
                        Else
                            Exit Sub
                        End If
                    Else
                        Exit Sub
                    End If
                End If
     
                'Create a new instance of Excel
                oExcel = CreateObject("Excel.Application")
                oBook = oExcel.Workbooks.Open(Filename:=nom_fichier & ".xls")
                oSheet = oExcel.ActiveSheet
                If oBook.ReadOnly = True Then
                    info.Text = "le fichier est déjà ouvert, veuillez fermer le fichier et Excel !"
                    System.Windows.Forms.Application.DoEvents()
                    oExcel.DisplayAlerts = False
                    oBook.close(Filename:=nom_fichier & ".xls")
                    oExcel.Quit()
                    oExcel.DisplayAlerts = True
                    oExcel = Nothing
                    oBook = Nothing
                    KillProcessus.KillProcessus("Excel")
                    Exit Sub
                Else
     
                    With oExcel.Sheets("suivi hotline")
     
                        i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("suivi hotline").Columns(1))
                        i = i + 1.0
                        ' demandeur
                        .Cells(i, 1).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 1).Value = TextBox3.Text
                        'noms ITC
                        .Cells(i, 2).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 2).Value = mesinfos.TextBox2.Text
                        ' date
                        .Cells(i, 3).Value = DateTimePicker1.Text
                        ' Temps passée
                        .Cells(i, 4).Value = ComboBox4.Text
                        ' client
                        .Cells(i, 5).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 5).Value = TextBox1.Text
                        ' contact client
                        .Cells(i, 6).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 6).Value = TextBox2.Text
                        ' N° SOON
                        .Cells(i, 7).Value = TextBox4.Text
                        ' code agence
                        .Cells(i, 8).Value = TextBox7.Text
                        'noms DEPARTEMENT
                        .Cells(i, 9).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 9).Value = ComboBox2.Text
                        ' famille
                        .Cells(i, 10).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 10).Value = ComboBox3.Text
                        'Questions
                        .Cells(i, 11) = Replace(TextBox6.Text, Chr(13) & Chr(10), " ")
                        'Réponse
                        .Cells(i, 12) = Replace(TextBox8.Text, Chr(13) & Chr(10), " ")
                        'email
                        .Cells(i, 13).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 13).Value = TextBox9.Text
                        'action
                        .Cells(i, 14).Value = TextBox10.Text
                        'téléphone
                        'appel du module pour espace tel.
                        telephone = TextBox14.Text
                        ESPACE.espace(telephone, TextBox14.Text)
                        System.Windows.Forms.Application.DoEvents()
                        .Cells(i, 15).Numberformat = "@" 'Cellules au format texte
                        .Cells(i, 15).Value = TextBox14.Text
     
     
                        'attribution n° hotline
     
                        If (.cells((i - 1), 16).value) < 1 Then
                            .cells(i, 16).value = 1
                        Else
                            .cells(i, 16).value = (.cells((i - 1), 16).value) + 1
                            numhot = .cells(i, 16).value
                        End If
     
     
     
     
                        'autoajustage des colonnes
                        .Cells.Columns.AutoFit()
     
                        'fermeture des instances Excel
                        oExcel.DisplayAlerts = False
                        If Val(oExcel.Version) > 11 Then
                            oBook.Saveas(Filename:=nom_fichier, FileFormat:=56)
                        Else
                            oBook.Saveas(Filename:=nom_fichier & ".xls")
                        End If
                        oBook.close(Filename:=nom_fichier & ".xls")
                        oExcel.Quit()
                        oExcel.DisplayAlerts = True
                        oSheet = Nothing
                        oExcel = Nothing
                        oBook = Nothing
                        KillProcessus.KillProcessus("Excel")
                        info.Text = "Enregistrement réussi !"
                        System.Windows.Forms.Application.DoEvents()
                        MsgBox("Votre N° de hotline local est : " & numhot, MsgBoxStyle.Information, AcceptButton)
                        Timer3.Enabled = True
                    End With
                    Exit Sub
                End If
            Else
     
                If CheckBox1.Checked = True Then
                    testconnexion.testconnexion()
                    If testok = True Then
                        If CheckBox3.Checked = False Then
                            principal.destinatairemail = TextBox9.Text
                        Else
                            principal.destinatairemail = TextBox9.Text & ";" & mesinfos.TextBox5.Text
                        End If
                        'appel du module pour espace tel.
                        telephone = TextBox14.Text
                        ESPACE.espace(telephone, TextBox14.Text)
                        System.Windows.Forms.Application.DoEvents()
                        principal.entetemail = "réponse de votre demande de hotline"
                        principal.messagemail = "Bonjour," & vbLf & vbLf & "Veuillez trouver ci-dessous notre réponse :" & vbLf & vbLf & "ITC de Hotline :  " & (mesinfos.TextBox2.Text) & vbLf & vbLf & "Date :  " & (DateTimePicker1.Text) & vbLf & vbLf & "Client :  " & (TextBox1.Text) & vbLf & vbLf & "Contact :  " & (TextBox2.Text) & vbLf & vbLf & "TEL :  " & (TextBox14.Text) & vbLf & vbLf & "Code Soon :  " & (TextBox4.Text) & vbLf & vbLf & "Question :  " & (TextBox6.Text) & vbLf & vbLf & "Réponse :  " & (TextBox8.Text) & vbLf & vbLf & "Action Commerciale à mener :  " & (TextBox10.Text) & vbLf & vbLf & "Temps Passée :  " & (ComboBox4.Text) & " .Minutes" & vbLf & vbLf & vbLf & "Vous en Souhaitant Bonne Réception." & vbLf & "Cordialement." & vbLf & vbLf & (mesinfos.TextBox2.Text)
                        principal.piecejointemail = Label11.Text
                        envoimail.envoimail()
                        If mailok = True Then
                        Else
                            Exit Sub
                        End If
                    Else
                        Exit Sub
                    End If
                End If
                'Create a new instance of Excel
                oExcel = CreateObject("Excel.Application")
                oBook = oExcel.Workbooks.Add
                oSheet = oExcel.ActiveSheet
     
                With oExcel.Sheets("Feuil1")
                    i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("feuil1").Columns(1))
                    i = i + 1.0
                    ' demandeur
                    .Cells(i, 1).Value = "DEMANDEUR"
                    'noms ITC
                    .Cells(i, 2).Value = "NOMS ITC"
                    ' date
                    .Cells(i, 3).Value = "DATE"
                    ' temps passée
                    .Cells(i, 4).Value = "TEMPS"
                    ' client
                    .Cells(i, 5).Value = "CLIENT"
                    ' contact client
                    .Cells(i, 6).Value = "CONTACT"
                    ' N° SOON
                    .Cells(i, 7).Value = "N° SOON"
                    ' code agence
                    .Cells(i, 8).Value = "CODE AGENCE"
                    'noms DEPARTEMENT
                    .Cells(i, 9).Value = "DEPARTEMENT"
                    ' famille
                    .Cells(i, 10).Value = "FAMILLE"
                    'Questions
                    .Cells(i, 11).Value = "QUESTIONS"
                    'Réponse
                    .Cells(i, 12).Value = "REPONSE"
                    'email
                    .Cells(i, 13).Value = "Email Demandeur"
                    'action
                    .Cells(i, 14).Value = "Action Commerciale ?"
                    'telephone
                    .Cells(i, 15).Value = "Tel Client"
                    'num hot
                    .Cells(i, 16).Value = "NUM HOTLINE"
     
                    i = i + 1
     
                    ' demandeur
                    .Cells(i, 1).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 1).Value = TextBox3.Text
                    'noms ITC
                    .Cells(i, 2).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 2).Value = mesinfos.TextBox2.Text
                    ' date
                    .Cells(i, 3).Value = DateTimePicker1.Text
                    ' Temps passée
                    .Cells(i, 4).Value = ComboBox4.Text
                    ' client
                    .Cells(i, 5).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 5).Value = TextBox1.Text
                    ' contact client
                    .Cells(i, 6).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 6).Value = TextBox2.Text
                    ' N° SOON
                    .Cells(i, 7).Value = TextBox4.Text
                    ' code agence
                    .Cells(i, 8).Value = TextBox7.Text
                    'noms DEPARTEMENT
                    .Cells(i, 9).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 9).Value = ComboBox2.Text
                    ' famille
                    .Cells(i, 10).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 10).Value = ComboBox3.Text
                    'Questions
                    .Cells(i, 11) = Replace(TextBox6.Text, Chr(13) & Chr(10), " ")
                    'Réponse
                    .Cells(i, 12) = Replace(TextBox8.Text, Chr(13) & Chr(10), " ")
                    'email
                    .Cells(i, 13).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 13).Value = TextBox9.Text
                    'action
                    .Cells(i, 14).Value = TextBox10.Text
                    'téléphone
                    'appel du module pour espace tel.
                    telephone = TextBox14.Text
                    ESPACE.espace(telephone, TextBox14.Text)
                    System.Windows.Forms.Application.DoEvents()
                    .Cells(i, 15).Numberformat = "@" 'Cellules au format texte
                    .Cells(i, 15).Value = TextBox14.Text
     
                    'attribution n° hotline
                    .cells(i, 16).value = 1
                    numhot = .cells(i, 16).value
     
                    .name = "suivi hotline" ' renomage de l'onglet
                    'autoajustage des colonnes
                    .Cells.Columns.AutoFit()
     
                End With
                With oExcel.Sheets("Feuil2")
                    i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("Feuil2").Columns(1))
     
                    i = i + 1.0
                    'creation nombre de demande incorrect
                    .Cells(i, 1).Value = "Demande Hotline incorrect"
                    ' demandeur
                    .Cells(i, 2).Value = "DEMANDEUR"
                    'noms ITC
                    .Cells(i, 3).Value = "NOMS ITC"
                    ' date
                    .Cells(i, 4).Value = "DATE"
                    .name = "demande incorrecte"
                    'autoajustage des colonnes
                    .Cells.Columns.AutoFit()
     
                End With
                With oExcel.Sheets("Feuil3")
                    i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("feuil3").Columns(1))
                    i = i + 1.0
                    ' demandeur
                    .Cells(i, 1).Value = "DEMANDEUR"
                    'noms ITC
                    .Cells(i, 2).Value = "NOMS ITC"
                    ' date
                    .Cells(i, 3).Value = "DATE"
                    ' temps passée
                    .Cells(i, 4).Value = "TEMPS"
                    ' client
                    .Cells(i, 5).Value = "CLIENT"
                    ' contact client
                    .Cells(i, 6).Value = "CONTACT"
                    ' N° DEVIS
                    .Cells(i, 7).Value = "N°DEVIS"
                    ' MONTANT
                    .Cells(i, 8).Value = "MONTANT"
                    'noms DEPARTEMENT
                    .Cells(i, 9).Value = "DEPARTEMENT"
                    ' famille
                    .Cells(i, 10).Value = "FAMILLE"
                    'Descriptif
                    .Cells(i, 11).Value = "DESCRIPTIF"
                    'telephone
                    .Cells(i, 12).Value = "Tel Client"
     
                    'implication avv
                    .Cells(i, 13).Value = "AVV Client"
                    'implication Définiton Produits
                    .Cells(i, 14).Value = "Définiton Produits"
                    'Validation Produits
                    .Cells(i, 15).Value = "Validation Produits"
                    'Relance Affaire
                    .Cells(i, 16).Value = "Suivi Affaire"
                    'Saisie Soon
                    .Cells(i, 17).Value = "Saisie Soon"
                    'Réserve
                    .Cells(i, 18).Value = "Traitement Solo"
     
                    .name = "suivi affaire" ' renomage de l'onglet
                    'autoajustage des colonnes
                    .Cells.Columns.AutoFit()
     
                    'fermeture des instances Excel
                    oExcel.DisplayAlerts = False
                    If Val(oExcel.Version) > 11 Then
                        oBook.Saveas(Filename:=nom_fichier, FileFormat:=56)
                    Else
                        oBook.Saveas(Filename:=nom_fichier & ".xls")
                    End If
                    oBook.close(Filename:=nom_fichier & ".xls")
                    oExcel.Quit()
                    oExcel.DisplayAlerts = True
                    oSheet = Nothing
                    oExcel = Nothing
                    oBook = Nothing
                    KillProcessus.KillProcessus("Excel")
                End With
     
                info.Text = "Enregistrement réussi !"
                System.Windows.Forms.Application.DoEvents()
                MsgBox("Votre N° de hotline local est : " & numhot, MsgBoxStyle.Information, AcceptButton)
                Timer3.Enabled = True
            End If
        End Sub

  15. #15
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    du bon vieux code illisible à la vb6 !


    li faut découper ton code, on ne fait pas des sub à rallonge ...

    et puis les If TextBox2.Text, If CheckBox1.Checked = True et autres If ComboBox3.SelectedIndex = 0 c'est du grand n'importe quoi
    autant les appeler a b et c pendant que tu y es ...

    dans 2 mois quand tu reliras le code tu saurais à quoi sert checkbox1 ?


    je ne suis pas sur que les Doevents soient utile

    et puis découpe moi ca en plusieurs parties, par exemple les vérification que tout est bien rempli sur le form tu le fais dans une fonction as boolean à part que tu nommes VerificationQueToutEstBienRempli

    if not VerificationQueToutEstBienRempli then exit sub c'est quand même plus lisible et ca n'a rien à faire dans une sub de traitement

    et puis vu qu'en cas d'erreur la pile des appels te dit dans quelle sub est le problème, avoir 10 subs permet de trouver facilement où ca plante


    il est aussi préférable de typer ses variables
    Dim i
    certes mais As quoi ??



    Citation Envoyé par Geo2A Voir le message
    Partager avec d'autres développeurs c'est important et formateur.
    espérons le pour lui ...
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  16. #16
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Âge : 55
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Par défaut
    ben tu as tout a fait raison, à ma décharge c'est mon 1er code et en plus il est très mal structuré du fait que je débute et ne comprend pas tout à fait la différence entre un module et une class. Mais ce n'es pas une excuse je ferais mieux la prochaine fois.

    pour l'heure j'ai un poste qui plante et comme vous pouvez le voir c'est pour mon boulot (le chef il me harcèle de question et je lui dit "???????????????")

    sinon j'ai peur de tout découper et que plus rien ne marche...
    (du code comme ça il y en a autant X 30 environ)

    Mais des pour des pros comme vous , c'est les doigt dans le nez ce petit code tout mal fait !

    merci de votre aide et remarque pertinente.

  17. #17
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    pour apprendre à développer :
    http://plasserre.developpez.com/cours/vb-net/


    sinon, met un try catch qui englobe toute la sub, créé une variable étape as integer
    toutes les 5 ou 10 lignes de code tu mets etape = 10
    etape = 20
    etape = 30
    etc...

    dans le catch tu mets msgbox ("erreur : etape = " & etape.tostring)

    tu executes sur le pc sur lequel ca plante et tu auras le dernier numéro d'étape passée
    ensuite entre cette etape et celle d'après tu mets une ligne d'étape entre chaque ligne
    etape = 21
    etape = 22
    etc...

    comme ca tu auras la ligne précise qui passe en erreur
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

Discussions similaires

  1. Plantage application xmlrad2006 sous Linux
    Par ulys dans le forum XMLRAD
    Réponses: 0
    Dernier message: 25/03/2008, 17h52
  2. Plantage d'un programme - cafree
    Par Freud44 dans le forum C++Builder
    Réponses: 15
    Dernier message: 26/01/2008, 12h37
  3. Réponses: 2
    Dernier message: 06/03/2007, 11h07
  4. [Debutant][XSL] Erreur de code programmation
    Par SkyDev dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 14/03/2006, 22h38
  5. Plantage application avec défaillance du module Kernel32
    Par cosminutza dans le forum Langage
    Réponses: 3
    Dernier message: 28/11/2005, 16h15

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