Private Function MidStr(ByVal Str As String, ByVal sStart As String, ByVal sEnd As String, Optional ByVal Start As Integer = 30) As String
Try
Dim iStart As Integer = Str.IndexOf(sStart, Start) + 1
Dim iEnd As Integer = Str.IndexOf(sEnd, iStart)
Return Str.Substring(iStart, iEnd - iStart)
Catch ex As Exception
Return String.Empty
End Try
End Function
comme on le voit ici, substring attend bien les positions. c'est aussi ce qu'indique clairement le message d'erreur
++
<hr size="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
dsigmoun
Messages postés135Date d'inscriptionjeudi 31 juillet 2008StatutMembreDernière intervention25 février 20232 9 déc. 2008 à 13:55
Voila j'ai rectifié une partie de ligne
Try
Dim iStart As Integer = Str.IndexOf(sStart, Start) + sStart.Length.ToString
Dim iEnd As Integer = Str.IndexOf(sEnd, iStart)
Return Str.Substring(iStart, iEnd - iStart)
Catch ex As Exception
Return String.Empty
End Try
dsigmoun
Messages postés135Date d'inscriptionjeudi 31 juillet 2008StatutMembreDernière intervention25 février 20232 8 déc. 2008 à 18:36
Voici le code que je viens de mettre. Cependant, j'ai le message d'erreur suivant : La conversion de la chaîne "<title>" en type 'Integer' n'est pas valide.
Dim webResponse As System.Net.WebResponse = Nothing
Dim path As String = adresse du lien
System.Windows.Forms.Application.DoEvents()
' Création de la request et demande de la response
webResponse = System.Net.WebRequest.Create(path) _
.GetResponse()
Dim streamReader As New System.IO.StreamReader(webResponse.GetResponseStream())
TextBox1.Text = streamReader.ReadToEnd()
webResponse.Close()