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 6 et antérieur Discussion :

[VB6] Message d'erreur


Sujet :

VB 6 et antérieur

  1. #1
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut [VB6] Message d'erreur
    Bonjour,
    Lorsque j'execute mon programme, au chargement de la form j'ai un message d'erreur qui apparait et je ne voit vrément pas pourquoi.

    le code:
    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
     
    If Dir(AppPath & "strQuit.txt", vbHidden) <> "" Then
            Open "strQuit.txt" For Input As #1
            Input #1, strQuit
            strQuit = strQuit + 1
            frmPeche.Caption = "Sortie n°" & strQuit
            Close #1
            Open "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
        Else
            strQuit = "0"
            Open "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
            Open "strQuit.txt" For Input As #1
            Input #1, strQuit
            strQuit = strQuit + 1
            frmPeche.Caption = "Sortie n°" & strQuit
            Close #1
            Open "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
        End If
    Le message d'erreur est :
    INPUT PAST END OF FILE.

    Lorsque je clique sur debug il me surligne la 3ème liqne.
    Merci d'avance.

  2. #2
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 040
    Points
    20 040
    Par défaut
    Citation Envoyé par fourgeaud
    Bonjour,
    (...)
    Le message d'erreur est :
    INPUT PAST END OF FILE.

    Lorsque je clique sur debug il me surligne la 3ème liqne.
    Merci d'avance.
    ben cela ve dire que tu lit trop de ligne dans ton fichier ...


    Pourquoi utilise tu appPAth .. pour tester si fichier existe :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If Dir(AppPath & "strQuit.txt", vbHidden) <> "" Then
    et puis plus d'appPAth pour l'ecriture/lecture///

  3. #3
    Membre actif Avatar de AdHoc
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 245
    Points : 239
    Points
    239
    Par défaut
    Testes la fin de fichiers ("EOF(filenumber)") et utilises Freefile avant tes open (en plus de ce que te préconnise bbil).

  4. #4
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut
    Bonjour,
    -Pour répondre à bbil, j'utilise appPath car le fichier créé lorsqu'on utilise output se crée automatiquement là où se trouve l'application. En fait appPath est le chemin de l'application, et strQuit, c'est le nom du fichier.
    -Pour répondre à adHOC, je n'utilise pas Freefile par ce que j'ai prit l'habitude de me servir des fichiers comme ça, en fait je ne connait pas l'avantage de Freefile, il faut que je me renseigne pour savoir merci.

    Et j'ai fait ce ke vous m'avez dit, et j'ai toujours le msg d'erreur.
    Merci à vous deux.

  5. #5
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut
    En fait ça marche comme ça:

    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
     
    If Dir(AppPath & "strQuit.txt", vbHidden) <> "" Then
            strQuit = "0"
            Open AppPath & "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
            Open AppPath & "strQuit.txt" For Input As #1
            Input #1, strQuit
            strQuit = strQuit + 1
            frmPeche.Caption = "Sortie n°" & strQuit
            Close #1
            Open AppPath & "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
        Else
            Open AppPath & "strQuit.txt" For Input As #1
            Input #1, strQuit
            strQuit = strQuit + 1
            frmPeche.Caption = "Sortie n°" & strQuit
            Close #1
            Open AppPath & "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
        End If
    Mais le problème c'est que ma form affiche toujours en caption "sortie n°1".
    Voila merci à tous et si quelqu'un sait pourquoi elle affiche toujours ça, peut-il le dire?
    En tout cas merci à tous.

  6. #6
    Inactif  
    Avatar de jmfmarques
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    3 784
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 3 784
    Points : 4 674
    Points
    4 674
    Par défaut
    Bien difficile de te répondre sans connaître les attributs de chacun des fichiers de ton répertoire, ma foi !

  7. #7
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut
    Escuse-moi mais qu'est-ce que tu appelles les attributs des fichiers de mon répertoire?

  8. #8
    Inactif  
    Avatar de jmfmarques
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    3 784
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 3 784
    Points : 4 674
    Points
    4 674
    Par défaut
    Tu n'as vraiment aucune idée de ce que sont les attributs d'un fichier ?
    TIENS !
    Et pourquoi, dans ce cas, utilise-tu un VbHidden dans ton code, alors.... c'est quoi, d'après toi ?...
    Cà, alors !...

  9. #9
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut
    En fait je l'ai prit dans la FAQ et je sait que vbHidden sert a ce que le fichier renvoit une réponse même si il est caché.
    Je n'ai pas un seul fichier caché dans le dossier de l'application.
    Merci.

  10. #10
    Expert confirmé
    Avatar de zazaraignée
    Profil pro
    Étudiant
    Inscrit en
    Février 2004
    Messages
    3 174
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2004
    Messages : 3 174
    Points : 4 085
    Points
    4 085
    Par défaut
    Salut pour avoir une information générale sur les attributs de fichiers, regarde dans l'aide de Windows.

    Dans VB l'aide en ligne peut te donner des informations sur les 'file attributes' (excuses... chez moi j'ai VB en Anglais, donc l'aide en anglais...) Ce qui donne:
    Citation Envoyé par MSDN
    The File List Box


    The file list box displays files contained in the directory specified by the Path property at run time. You can display all the files in the current directory on the current drive using the following statement:

    File1.Path = Dir1.Path

    You can then display a subset of these files by setting the Pattern property — for example, *.frm displays only files with that extension. The Pattern property can also accept a list delimited by semicolons. For example, a line with the following code displays all files with the extensions .frm and .bas:

    File1.Pattern = "*.frm; *.bas"

    Visual Basic supports the ? wildcard character. For instance, ???.txt displays files that have base names of only three characters with the extension .txt.
    C'est ici que ça devient intéressant...
    Working with File Attributes
    The attributes of the currently selected file (Archive, Normal, System, Hidden, and ReadOnly) are also available through file list box properties. You use these properties to specify which kinds of files to display in a file list box. The default value for the System and Hidden attributes is False. The default value for the Normal, Archive, and ReadOnly attributes is True.

    To display only read-only files in the list box, for example, simply set the ReadOnly property to True and the other attribute properties to False:

    File1.ReadOnly = True
    File1.Archive = False
    File1.Normal = False
    File1.System = False
    File1.Hidden = False

    When Normal = True, those files without the System or Hidden attribute are displayed. When Normal = False, you can still display files with ReadOnly and/or Archive attributes by setting these attributes to True.

    Note You cannot use the attribute properties to set file attributes. To set file attributes, use the SetAttr statement.

    By default, you can highlight only a single selection in a file list box. To select multiple files, use the MultiSelect property.

    For More Information For more information on SetAttr, see "SetAttr Statement." Also see "MultiSelect Property."

  11. #11
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut
    Merci zazaraignée, Pour réponde à jmfmarques, je n'ai pas mit d'attributs à mes fichiers.

  12. #12
    Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    88
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 88
    Points : 53
    Points
    53
    Par défaut
    J'ai trouvé le problème, il se situé à la première ligne, il fallait que dir() renvoit le nom du fichier :

    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
     
    If Dir(AppPath & "strQuit.txt", vbHidden) = "strQuit.txt" Then
            Open AppPath & "strQuit.txt" For Input As #1
            Input #1, strQuit
            strQuit = strQuit + 1
            frmPeche.Caption = "Sortie n°" & strQuit
            Close #1
            Open AppPath & "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
        Else
            strQuit = "0"
            Open AppPath & "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
            Open AppPath & "strQuit.txt" For Input As #1
            Input #1, strQuit
            strQuit = strQuit + 1
            frmPeche.Caption = "Sortie n°" & strQuit
            Close #1
            Open AppPath & "strQuit.txt" For Output As #1
            Print #1, strQuit
            Close #1
        End If
    Merci à tous pour votre aide.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VB6]Message d'erreur si le temps d'exécution est trop long
    Par Asdorve dans le forum VB 6 et antérieur
    Réponses: 16
    Dernier message: 14/09/2006, 16h43
  2. [VB6] Message d'erreur: Projet ou bibliotheque introuvable
    Par bvi67 dans le forum VB 6 et antérieur
    Réponses: 10
    Dernier message: 20/05/2006, 12h00
  3. [VB6]sqlserver 2000 message d'erreur
    Par Abydos Business Group dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 24/03/2006, 19h33
  4. [VB6]affichage d'une feuille modale / message d'erreur 400
    Par getea85 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 26/01/2006, 18h37
  5. Réponses: 2
    Dernier message: 27/05/2002, 19h46

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