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

Windows Forms Discussion :

[bug] ecriture dans fichier texte


Sujet :

Windows Forms

  1. #1
    Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Juin 2006
    Messages
    104
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2006
    Messages : 104
    Points : 58
    Points
    58
    Par défaut [bug] ecriture dans fichier texte
    Bonjour à tous,

    J'ai un problème qui me bloque complèment...

    J'ai une procédure d'enregistrement qui me sauvegarde dans un fichier texte plein d'informations de plusieurs formulaires...
    Jusqu'à hier cela marchait...


    Maintenant quand je sauvegarde toutes les informations ne sont pas enregistrer. Pourtant j'ai pas à ma connaissance rien fait qui puisse cause ce problème.

    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
     Public Sub Enregistrer()
     
            Dim DateJour As String
            DateJour = Date.Now.ToString("ddMMyy")
     
            Dim SWGlobal As StreamWriter = New StreamWriter("\My Documents\aip_ressources\Sauvegarde\" & Information.CodePSV & "_" & DateJour & ".txt")
     
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine(Information.CodePSV)
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("Information du Prélèvement :")
            SWGlobal.WriteLine("")
            SWGlobal.Write("Commune :")
            SWGlobal.WriteLine(Information.Box_Commune.Text)
            SWGlobal.Write("Type D'installation :")
            SWGlobal.WriteLine(Information.Box_Type_Installation.Text)
            SWGlobal.Write("Payeur :")
            SWGlobal.WriteLine(Information.Box_Payeur.Text)
            SWGlobal.Write("Installation :")
            SWGlobal.WriteLine(Information.Box_Installation.Text)
            SWGlobal.Write("Nom du PSV :")
            SWGlobal.WriteLine(Information.Box_Nom_PSV.Text)
            SWGlobal.Write("Lieu du PSV :")
            SWGlobal.WriteLine(Information.Box_Lieu_PSV.Text)
            SWGlobal.Write("Type d'eau :")
            SWGlobal.WriteLine(Information.Box_Type_Eau.Text)
            SWGlobal.Write("Responsable :")
            SWGlobal.WriteLine(Information.Box_Responsable.Text)
            SWGlobal.Write("Eau Influencée :")
            If Information.CheckBox_Eau.Checked = True Then
                SWGlobal.WriteLine("oui")
            Else
                SWGlobal.WriteLine("non")
            End If
            SWGlobal.Write("Option :")
            If Information.CheckBox_Option.Checked = True Then
                SWGlobal.WriteLine("oui")
            Else
                SWGlobal.WriteLine("non")
            End If
     
     
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("Appareils utilisés :")
            SWGlobal.WriteLine("")
            SWGlobal.Write("PHMètre :")
            SWGlobal.WriteLine(Materiels.Box_PH_Metre.Text)
            SWGlobal.Write("Conductimètre :")
            SWGlobal.WriteLine(Materiels.Box_Conductimetre.Text)
            SWGlobal.Write("Colorimètre utilisés :")
            SWGlobal.WriteLine(Materiels.Box_Colorimetre.Text)
            SWGlobal.Write("Photomètre :")
            SWGlobal.WriteLine(Materiels.Box_Photometre.Text)
            SWGlobal.Write("Oxymètre :")
            SWGlobal.WriteLine(Materiels.Box_Oxymetre.Text)
            SWGlobal.Write("Thermomètre :")
            SWGlobal.WriteLine(Materiels.Box_Thermometre.Text)
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("Mesures de Terrains :")
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine(Nom_Preleveur)
            SWGlobal.WriteLine("")
            SWGlobal.Write("Date du prélèvement :")
            SWGlobal.WriteLine(Mesure.Label_Date.Text)
            SWGlobal.Write("Heure d'enregistrement :")
            SWGlobal.WriteLine(Mesure.Label_Heure.Text)
            SWGlobal.Write("")
            SWGlobal.Write("Temps de Purge : (en s)")
            SWGlobal.WriteLine(Mesure.Box_Purge.Text)
            SWGlobal.Write("")
            SWGlobal.Write("Mesure de PH (en unité PH) :")
            SWGlobal.WriteLine(Mesure.Box_PH.Text)
            SWGlobal.Write("Conductivité (en µs/cm) :")
            SWGlobal.WriteLine(Mesure.Box_Conductivite.Text)
            SWGlobal.Write("Température eau (en °C) :")
            SWGlobal.WriteLine(Mesure.Box_Temperature_Eau.Text)
            SWGlobal.Write("Pression (en mBar) :")
            SWGlobal.WriteLine(Mesure.Box_Pression.Text)
            SWGlobal.Write("Oxigène Dissous (en mg/L) :")
            SWGlobal.WriteLine(Mesure.Box_O_Dissous.Text)
            SWGlobal.Write("Chlore Libre (en mg/L) :")
            SWGlobal.WriteLine(Mesure.Box_CH_Libre.Text)
            SWGlobal.Write("Chlore Total(en mg/L) :")
            SWGlobal.WriteLine(Mesure.Box_CH_Total.Text)
            SWGlobal.Write("Nombre de Flacons :")
            SWGlobal.WriteLine(Mesure.Box_Flacons.Text)
            SWGlobal.Write("type d'Analyse :")
            SWGlobal.WriteLine(Mesure.Box_Type_Analyse.Text)
            SWGlobal.Write("Type de visite :")
            SWGlobal.WriteLine(Mesure.Box_Type_Visite.Text)
            SWGlobal.Write("Désinfection :")
     
            If Mesure.Box_Desinfection.Text = "Autre" Then
                SWGlobal.Write(Mesure.Box_Desinfection.Text)
                SWGlobal.Write(" (")
                SWGlobal.Write(Mesure.TypeDesinfection)
                SWGlobal.WriteLine(")")
            Else
                SWGlobal.WriteLine(Mesure.Box_Desinfection.Text)
            End If
     
            SWGlobal.Write("Localisation Précise :")
            SWGlobal.WriteLine(Mesure.Box_Localisation.Text)
            SWGlobal.Write("Point de Prélèvement :")
     
     
            If Mesure.Box_Pt_Prelevement.Text = "Autre" Then
                SWGlobal.Write(Mesure.Box_Pt_Prelevement.Text)
                SWGlobal.Write(" (")
                SWGlobal.Write(Mesure.PtPrelevement)
                SWGlobal.WriteLine(")")
            Else
                SWGlobal.WriteLine(Mesure.Box_Pt_Prelevement.Text)
            End If
     
     
     
     
            SWGlobal.Write("Aspect :")
            SWGlobal.WriteLine(Mesure.Box_Aspect.Text)
            SWGlobal.Write("Couleur :")
            SWGlobal.WriteLine(Mesure.Box_Couleur.Text)
            SWGlobal.Write("Odeur :")
            SWGlobal.WriteLine(Mesure.Box_Odeur.Text)
            SWGlobal.Write("Saveur :")
            SWGlobal.WriteLine(Mesure.Box_Saveur.Text)
     
     
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("")
            SWGlobal.WriteLine("Commentaire :")
            SWGlobal.WriteLine(BlocNote.Box_BlocNote.Text)
            SWGlobal.WriteLine("ceci  est un test")
            SWGlobal.WriteLine(Mesure.Box_PH.Text)
            SWGlobal.Close()
     
     
        End Sub
    Dans mon fichier il m'affiche actuellement tous les "texte qui se trouve dans le code
    - le code psv:
    SWGlobal.WriteLine(Information.CodePSV)
    - ces deux champs (liés a des checkbox)
    SWGlobal.Write("Eau Influencée :")
    If Information.CheckBox_Eau.Checked = True Then
    SWGlobal.WriteLine("oui")
    Else
    SWGlobal.WriteLine("non")
    End If
    SWGlobal.Write("Option :")
    If Information.CheckBox_Option.Checked = True Then
    SWGlobal.WriteLine("oui")
    Else
    SWGlobal.WriteLine("non")
    End If
    - Le materiel
    SWGlobal.WriteLine("")
    SWGlobal.WriteLine("")
    SWGlobal.WriteLine("Appareils utilisés :")
    SWGlobal.WriteLine("")
    SWGlobal.Write("PHMètre :")
    SWGlobal.WriteLine(Materiels.Box_PH_Metre.Text)
    SWGlobal.Write("Conductimètre :")
    SWGlobal.WriteLine(Materiels.Box_Conductimetre.Text)
    SWGlobal.Write("Colorimètre utilisés :")
    SWGlobal.WriteLine(Materiels.Box_Colorimetre.Text)
    SWGlobal.Write("Photomètre :")
    SWGlobal.WriteLine(Materiels.Box_Photometre.Text)
    SWGlobal.Write("Oxymètre :")
    SWGlobal.WriteLine(Materiels.Box_Oxymetre.Text)
    SWGlobal.Write("Thermomètre :")
    SWGlobal.WriteLine(Materiels.Box_Thermometre.Text)
    SWGlobal.WriteLine("")
    SWGlobal.WriteLine("")
    et Le preleveur, la date et l'heure

    SWGlobal.WriteLine(Nom_Preleveur)
    SWGlobal.WriteLine("")
    SWGlobal.Write("Date du prélèvement :")
    SWGlobal.WriteLine(Mesure.Label_Date.Text)
    SWGlobal.Write("Heure d'enregistrement :")
    SWGlobal.WriteLine(Mesure.Label_Heure.Text)
    Pourquoi il m'affiche pas le reste? :/
    Le code a deja fonctionné, de plus s'il affiche une partie il doit bien pouvoir afficher le reste... je comprends plus rien.

    Une idée de la source du problème?

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    138
    Détails du profil
    Informations personnelles :
    Âge : 53
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2007
    Messages : 138
    Points : 121
    Points
    121
    Par défaut
    Salut,

    Il ne te manque pas un
    à la fin pour tout écrire?

  3. #3
    Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Juin 2006
    Messages
    104
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2006
    Messages : 104
    Points : 58
    Points
    58
    Par défaut
    Si je dis pas de betise il me semble que le ME.close() par defaut "Flush".

    Et meme si je flush puis je close j'ai toujours le même problème.

    je comprends pas...

    Edit:
    Pour faire un test j'ai enregistré le contenu de la textbox dans une variable
    variable = textbox.text
    puis j'ai écrit le contenu de la varaible et la ca marche.
    Swglobal.writeline(variable)


    pourquoi quand j'enregistre directement le contenu ca marche pas alors?
    Swglobal.writeline(variable) ==> fonctionne
    Swglobal.writeline(textbox.text) ==> ne fonctionne pas
    (pourtant quand j'enregistre je suis certain que mes textbox ne sont pas vide)

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    138
    Détails du profil
    Informations personnelles :
    Âge : 53
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2007
    Messages : 138
    Points : 121
    Points
    121
    Par défaut
    J'avais déjà eu un problème de ce genre. Maisje ne sais plus hélàs trop le pourquoi du comment.
    Essaie ça peut-être:
    Swglobal.writeline(textbox.text.tostring)

Discussions similaires

  1. Ecriture tableaux de tableaux dans fichier texte
    Par Adjen dans le forum MATLAB
    Réponses: 3
    Dernier message: 16/09/2014, 15h36
  2. Ecriture dans fichier texte
    Par Gannox dans le forum Langage
    Réponses: 0
    Dernier message: 17/12/2012, 16h05
  3. Réponses: 14
    Dernier message: 22/05/2011, 12h21
  4. ecriture dans fichier texte
    Par nicofan dans le forum C++
    Réponses: 1
    Dernier message: 28/09/2007, 13h28
  5. Problèmes Ecriture dans Fichiers Texte
    Par JmL40 dans le forum Langage
    Réponses: 13
    Dernier message: 26/09/2007, 14h04

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