VB - Récupérer la mise à jour d'un blog
Résolu
laguernette
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
laguernette Messages postés 6 Date d'inscription Statut Membre Dernière intervention -
laguernette Messages postés 6 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je cherche à récupérer dans une textbox la dernière mise à jour d'un blog. Pouvez-vous m'aider svp ?
J'ai essayé avec webrequest mais ne maîtrisant pas la fonction, j'ai échoué.
J'ai aussi essayé une méthode dérivée en ouvrant le site web avec excel mais mon code ne semble pas être correct :
Je cherche à récupérer dans une textbox la dernière mise à jour d'un blog. Pouvez-vous m'aider svp ?
J'ai essayé avec webrequest mais ne maîtrisant pas la fonction, j'ai échoué.
J'ai aussi essayé une méthode dérivée en ouvrant le site web avec excel mais mon code ne semble pas être correct :
Dim appExcel As Excel.Application Dim wbExcel As Excel.Workbook Dim wsExcel As Excel.Worksheet Dim ValAChercher, ValARenvoyer Dim c As Range appExcel = CreateObject("Excel.Application") wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr/") wsExcel = wbExcel.Worksheets(1) 'wsExcel ValAChercher = "Mise à jour :" With wsExcel.Range("a1:a500") c = .Find(ValAChercher) If Not c Is Nothing Then ValARenvoyer = c.Offset(0, 1).Value Textbox1.text = ValARenvoyer End If End With
A voir également:
- VB - Récupérer la mise à jour d'un blog
- Mise a jour chrome - Accueil - Applications & Logiciels
- Mise a jour windows 10 - Accueil - Mise à jour
- Mise a jour chromecast - Accueil - Guide TV et vidéo
- Comment recuperer un message supprimé sur whatsapp - Guide
- Mise à jour libre office - Accueil - Bureautique
2 réponses
le form1.vb :
Imports System.Net.Mime.MediaTypeNames
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim appExcel As Application
Dim wbExcel As Excel.Worksheet
Dim wsExcel As Excel.Worksheet
Dim ValAChercher, ValARenvoyer
Dim c As Range
appExcel = CreateObject("Excel.Application")
wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr/")
wsExcel = wbExcel.Worksheets(1) 'wsExcel
ValAChercher = "Mise à jour :"
With wsExcel.Range("a1:a500")
c = .Find(ValAChercher)
If Not c Is Nothing Then
ValARenvoyer = c.Offset(0, 1).Value
TextBox1.Text = ValARenvoyer
End If
End With
End Sub
End Class
Le WorkSheet.vb:
Namespace Excel
Class Worksheet
Function Worksheets(p1 As Integer) As Worksheet
Throw New NotImplementedException
End Function
Function Range(p1 As String) As Object
Throw New NotImplementedException
End Function
End Class
End Namespace
Imports System.Net.Mime.MediaTypeNames
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim appExcel As Application
Dim wbExcel As Excel.Worksheet
Dim wsExcel As Excel.Worksheet
Dim ValAChercher, ValARenvoyer
Dim c As Range
appExcel = CreateObject("Excel.Application")
wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr/")
wsExcel = wbExcel.Worksheets(1) 'wsExcel
ValAChercher = "Mise à jour :"
With wsExcel.Range("a1:a500")
c = .Find(ValAChercher)
If Not c Is Nothing Then
ValARenvoyer = c.Offset(0, 1).Value
TextBox1.Text = ValARenvoyer
End If
End With
End Sub
End Class
Le WorkSheet.vb:
Namespace Excel
Class Worksheet
Function Worksheets(p1 As Integer) As Worksheet
Throw New NotImplementedException
End Function
Function Range(p1 As String) As Object
Throw New NotImplementedException
End Function
End Class
End Namespace
Merci, mais j'ai finalement opté pour la solution suivante :
Dim appExcel As Excel.Application 'Application Excel Dim wbExcel As Excel.Workbook 'Classeur Excel Dim wsExcel As Excel.Worksheet 'Feuille Excel 'Déclaration des variables appExcel = CreateObject("Excel.Application") 'Ouverture de l'application Excel wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr") 'Ouverture d'un fichier Excel wsExcel = wbExcel.Worksheets(1) 'wsExcel Dim Maj As Integer Dim Chr As Integer For Maj = 1 To 650 If InStr(wsExcel.Range("A" & Maj).Value, "Updated") <> 0 Then TextBox1.Text = "Le mot - Updated - existe dans la cellule A" & Maj TextBox2.Text = InStr(wsExcel.Range("A" & Maj).Value, "Updated") Chr = TextBox2.Text TextBox3.Text = Microsoft.VisualBasic.Mid(wsExcel.Range("A" & Maj).Value, Chr + 9, 8) End If Next Maj wbExcel.Close(False) '(referme la page Web) appExcel.Quit() 'Fermeture de l'application Excel wsExcel = Nothing 'Désallocation mémoire wbExcel = Nothing 'Désallocation mémoire appExcel = Nothing 'Désallocation mémoire