Ouvrir un fichier distant

cs_Moria Messages postés 31 Date d'inscription lundi 29 juillet 2002 Statut Membre Dernière intervention 12 septembre 2002 - 29 juil. 2002 à 15:27
druggedsephiroth Messages postés 71 Date d'inscription samedi 18 mai 2002 Statut Membre Dernière intervention 19 juin 2003 - 29 juil. 2002 à 21:02
Slt,

J'aimerais savoir comment faire pour ouvrir un fichier txt se trouvant sur internet :
http://www.site.com/test.txt
Et comment faire un retour à la ligne dans les objet : Text

@+

6 réponses

druggedsephiroth Messages postés 71 Date d'inscription samedi 18 mai 2002 Statut Membre Dernière intervention 19 juin 2003
29 juil. 2002 à 15:47
Pour ta deuxième question, il suffit de faire
text1.text = text1.text & vbcrlf

Et pour ta première question c'est un peu plus compliqué, moi en tout cas je le ferais avec un winsock et le code suivant (1 bouton, 1 winsock, 1 textbox):

Private sub command1_click()
Winsock1.connect "www.tonserveur.com",80
end sub

private sub winsock1_connect()
Winsock1.SendData "GET /test.txt" & vbCrLf & _
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" & vbCrLf & _
"Accept-Language: fr-ch" & vbCrLf & _
"Accept-Encoding: gzip, deflate" & vbCrLf & _
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" & vbCrLf & _
"Host: 195.65.51.165" & vbCrLf & _
"Connection: Keep-Alive" & vbCrLf & vbCrLf
end sub

private sub winsock1_dataarrival(ByVal bytesTotal As Long)
dim donnees as string
winsock1.getdata donnees
text1.text = text1.text & donnees
end sub
0
druggedsephiroth Messages postés 71 Date d'inscription samedi 18 mai 2002 Statut Membre Dernière intervention 19 juin 2003
29 juil. 2002 à 15:49
Hum, petite erreur, dans la ligne "Host: 195.65.51.165"

Remplace l'ip par: "http://www.site.com"
0
cs_Moria Messages postés 31 Date d'inscription lundi 29 juillet 2002 Statut Membre Dernière intervention 12 septembre 2002
29 juil. 2002 à 16:26
Erreur :

Il me dit un objet est requis !
Et surligne la ligne Winsock !

Coment on creer un objet winsock c dans kel menu ?

@+
0
cs_Moria Messages postés 31 Date d'inscription lundi 29 juillet 2002 Statut Membre Dernière intervention 12 septembre 2002
29 juil. 2002 à 16:52
J'ai trouver pour Winsock mais ca marche pas ca ne marche rien dans le TextBox :(
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
druggedsephiroth Messages postés 71 Date d'inscription samedi 18 mai 2002 Statut Membre Dernière intervention 19 juin 2003
29 juil. 2002 à 18:44
Je viens d'essayer avec google et ca marche, prends cet exemple et essaie, ca devrait marcher, ensuite il te reste qu'à changer l'url...

Private Sub command1_click()
Winsock1.Connect "www.google.fr", 80
End Sub

Private Sub winsock1_connect()
Winsock1.SendData "GET /index.html" & vbCrLf & _
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" & vbCrLf & _
"Accept-Language: fr-ch" & vbCrLf & _
"Accept-Encoding: gzip, deflate" & vbCrLf & _
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" & vbCrLf & _
"Host: http://www.google.fr" & vbCrLf & _
"Connection: Keep-Alive" & vbCrLf & vbCrLf
End Sub

Private Sub winsock1_dataarrival(ByVal bytesTotal As Long)
Dim donnees As String
Winsock1.GetData donnees
Text1.Text = Text1.Text & donnees
End Sub
0
druggedsephiroth Messages postés 71 Date d'inscription samedi 18 mai 2002 Statut Membre Dernière intervention 19 juin 2003
29 juil. 2002 à 21:02
Heu je sais pas pourquoi il a mis mon message au dessus du tien... voila...:

Je viens d'essayer avec google et ca marche, prends cet exemple et essaie, ca devrait marcher, ensuite il te reste qu'à changer l'url...

Private Sub command1_click()
Winsock1.Connect "www.google.fr", 80
End Sub

Private Sub winsock1_connect()
Winsock1.SendData "GET /index.html" & vbCrLf & _
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" & vbCrLf & _
"Accept-Language: fr-ch" & vbCrLf & _
"Accept-Encoding: gzip, deflate" & vbCrLf & _
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" & vbCrLf & _
"Host: http://www.google.fr" & vbCrLf & _
"Connection: Keep-Alive" & vbCrLf & vbCrLf
End Sub

Private Sub winsock1_dataarrival(ByVal bytesTotal As Long)
Dim donnees As String
Winsock1.GetData donnees
Text1.Text = Text1.Text & donnees
End Sub
0
Rejoignez-nous