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] Ouvrir un fichier text qui ce trouve sur internet!


Sujet :

VB 6 et antérieur

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2004
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Savoie (Rhône Alpes)

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

    Informations forums :
    Inscription : Août 2004
    Messages : 27
    Points : 26
    Points
    26
    Par défaut [VB6] Ouvrir un fichier text qui ce trouve sur internet!
    Bonjour,
    je voudrait ouvrir un fichier qui ce trouve sur internet (http://www.passiblog.com/404.txt), quel solution faut t'il faire??

    Pour ouvrir un fichier sur mon disque dur j'utilisé ce script :
    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
     
    Sub chargedonnee()
    Dim Fichier As String
    Dim ligne As String
    tailletab = 0
    Fichier = "c//404.txt"
    If Fichier = "" Then Exit Sub
    Open Fichier For Input As #1
    While Not EOF(1)
        Line Input #1, ligne
         If ligne <> "" Then
            ReDim Preserve Tabdonnee(tailletab + 1)
            Tabdonnee(tailletab) = ligne
            tailletab = tailletab + 1
        End If
    Wend
    Close #1
     
    End Sub

  2. #2
    Membre expérimenté Avatar de Megaxel
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    1 187
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 1 187
    Points : 1 405
    Points
    1 405
    Par défaut
    Salut!
    Il me semble bien qu'on a eu la réponse à cette question la semaine dernière. Remonte un peu sur les 3 dernières pages de sujets, et tu devrais trouver.

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2004
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Savoie (Rhône Alpes)

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

    Informations forums :
    Inscription : Août 2004
    Messages : 27
    Points : 26
    Points
    26
    Par défaut
    j'ai trouvé ce message > http://www.developpez.net/forums/viewtopic.php?t=478592

    mais je n'arrive pas à faire marcher ce code correctement.

    que doit je modifier?

    merci

  4. #4
    Expert éminent
    Avatar de ThierryAIM
    Homme Profil pro
    Inscrit en
    Septembre 2002
    Messages
    3 673
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2002
    Messages : 3 673
    Points : 8 524
    Points
    8 524
    Par défaut
    1ere solution : récuperer le fichier sur ton disque (tu peux ensuite l'ouvrir avec ton code)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
            "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
            ByVal szFileName As String, ByVal dwReserved As Long, _
            ByVal lpfnCB As Long) As Long
     
    Private Sub Form_Load()
        URLDownloadToFile 0, "http://www.passiblog.com/404.txt", "c:\404.txt" & ufile, 0, 0
    End Sub
    2e solution: lire le fiichier directement et le charger dans un buffer texte :
    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
    Const scUserAgent = ""
    Const INTERNET_OPEN_TYPE_DIRECT = 1
    Const INTERNET_OPEN_TYPE_PROXY = 3
    Const INTERNET_FLAG_RELOAD = &H80000000
     
    Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
    Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
    Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
    Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
     
     
    Private Sub Command1_Click()
        Dim hOpen As Long, hFile As Long, sBuffer As String, hRet As Long
        'Create a buffer for the file we're going to download
        sBuffer = Space(20000)
        'Create an internet connection
        hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
        'Open the url
        hFile = InternetOpenUrl(hOpen, "http://www.passiblog.com/404.txt", vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
        'Lit le fichier > buffer
        InternetReadFile hFile, sBuffer, Len(sBuffer), hRet
        'clean up
        InternetCloseHandle hFile
        InternetCloseHandle hOpen
     
        '-- recuperer la chaine lue
        Contents = Trim(sBuffer)
        Debug.Print Contents
    End Sub

  5. #5
    Membre expérimenté Avatar de Megaxel
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    1 187
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 1 187
    Points : 1 405
    Points
    1 405
    Par défaut
    Harg... Il me restait 46h21' à attendre avant de mettre la première solution. (La deuxième, c'est trop fort pour moi...)

    (Bon, et j'arrête avec ce truc de "2 jours"...)

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2004
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Savoie (Rhône Alpes)

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

    Informations forums :
    Inscription : Août 2004
    Messages : 27
    Points : 26
    Points
    26
    Par défaut
    Impecable

    Merci beaucoup ça marche parfaitement

  7. #7
    Membre expérimenté Avatar de Megaxel
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    1 187
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 1 187
    Points : 1 405
    Points
    1 405
    Par défaut
    C'est bizarre, je ne vois pas le tag [Résolu] ?
    Allez, allez, malgré la bonne humeur évidente de certains membres de ce forum, il ne faut pas se relacher et oublier les gestes essentiels: un click sur le bouton

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

Discussions similaires

  1. Réponses: 0
    Dernier message: 11/05/2015, 17h28
  2. Lancer une video qui se trouve sur internet
    Par pelerin98 dans le forum Excel
    Réponses: 3
    Dernier message: 24/11/2014, 20h14
  3. Réponses: 5
    Dernier message: 09/07/2012, 19h27
  4. Lire un ini qui se trouve sur internet
    Par Colbix dans le forum Langage
    Réponses: 2
    Dernier message: 11/03/2010, 09h11
  5. [PDF] Ouvrir et lire un fichier pdf qui se trouve sur ma machine
    Par essse dans le forum Bibliothèques et frameworks
    Réponses: 4
    Dernier message: 08/03/2009, 13h45

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