marty14
Messages postés104Date d'inscriptionlundi 21 août 2006StatutMembreDernière intervention29 mai 2011
-
30 juin 2009 à 04:13
marty14
Messages postés104Date d'inscriptionlundi 21 août 2006StatutMembreDernière intervention29 mai 2011
-
1 juil. 2009 à 15:08
Bonjour,
Est il possible de faire tourner ce code 10 fois d'affiler
tout en changeant le nombre de course d'inscrit
EX premiere execution scourse 1 Pcourse 2
EX deuxieme execution scourse 2 Pcourse 3
S = InStr(1502, gg, "Course 6 :")
P = InStr(1620, gg, "Course 7 :")
If P False Then P InStr(i + 1, gg, "Réunion 2")
Form1.Text11.Text = Mid(gg, S, P - (S + 5))
If InStr(1, Form1.Text11.Text, (" 1,1 ")) Then MsgBox "bravo"
If (Exists(" 14 partants ") Or Exists(" 15 partants ") Or Exists(" 16 partants ") Or Exists(" 17 partants ") Or Exists(" 18 partants ") Or Exists(" 19 partants ") Or Exists(" 20 partants ")) _
And _
(Exists(" 1,6 ") Or Exists(" 1,5 ") Or Exists(" 1,4 ") Or Exists(" 1,3 ") Or Exists(" 1,2 ") Or Exists(" 1,1 ")) Then
MsgBox "bravo"
Beep
End If
2 - scanner toutes les courses existante sur cette page et les afficher dans un textBox
For i = 1 To 10 Step 2
S = InStr(1, gg, "Réunion 1")
S = InStr(S, gg, "Course " & i & " :")
If S Then
Beep
P = InStr(S + 1, gg, "Course " & i + 1 & " :")
If P False Then P InStr(i + 1, gg, "Réunion 2")
Text11.Text = Mid(gg, S, P - (S + 5))
End If
If InStr(1, Text11.Text, (" 1,1 ")) Then MsgBox "bravo"
If (Exists(" 14 partants ") Or Exists(" 15 partants ") Or Exists(" 16 partants ") Or Exists(" 17 partants ") Or Exists(" 18 partants ") Or Exists(" 19 partants ") Or Exists(" 20 partants ")) _
And _
(Exists(" 1,6 ") Or Exists(" 1,5 ") Or Exists(" 1,4 ") Or Exists(" 1,3 ") Or Exists(" 1,2 ") Or Exists(" 1,1 ")) Then
MsgBox "bravo"
Beep
End If
Next i
Pour le moment les actions BEEP ET MSGBOX sont volontaire en attendant de veritable action, j'ai testé le code que vous m'avez fournis mais il ne fonctionne pas, il m'affiche tous le contenus de la page web dans mon textbox.
S = InStr(1502, gg, "Course " & i & " :")
P = InStr(1620, gg, "Course " & i+1 & " :")
alors que normalement c'est course par course, S InStr(1502, gg, "Course 1") et P InStr(1620, gg, "Course 2") fonctionne trés bien mais j'ai besoin d'exectuter mon code 10 fois tout en changeant le numero des course automatiquement.
Pour peaufiner j'aimerais utiliser un progressbar en fonction du nombre d'execution de ce code .
marty14
Messages postés104Date d'inscriptionlundi 21 août 2006StatutMembreDernière intervention29 mai 2011 1 juil. 2009 à 10:15
J'utilise le meme code mais avec une source html cette fois ci! c'est ca ?
A l'okasion pouvez vous me donner un petit exemple accompagné d'un progressbar svp ?
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 1 juil. 2009 à 12:42
testé avec succès avec le code HTML enregistré en local:
Option Explicit
Private Type Participant
NumID As String
Favori As Boolean
Cote As Single
Partant As Boolean
End Type
Private Type Course
Nom As String
NbParticipants As Long
Participants() As Participant
HeureCourse As Date
HeureReleve As Date
End Type
Private Type Reunion
Nom As String
Temperature As Integer
DirectionVent As String
VitesseVent As Integer
Ciel As String
NbCourses As Long
Courses() As Course
End Type
Private mNbReunions As Long
Private mxtReunions() As Reunion
Private Sub Form_Load()
Dim sBuffer As String
Open "C:\a.html" For Input As 1
sBuffer = Input(LOF(1), 1)
Close #1
LoadPage sBuffer
'# On peu ici jouer avec le tableau mxtReunions, qui contien les infos de notre page
End Sub
Private Sub LoadPage(ByRef vsHTMLContent As String)
Dim oMatch As Object
With CreateObject("VbScript.RegExp")
.Pattern = ">Réunion \d+ : (.+?) *<[\s\S]+?alt=""(.+?)"" /> (\d+).+?, (\d+).+?, (.+?)\r([\s\S]+?)
"
.Global = True
.MultiLine = True
For Each oMatch In .Execute(vsHTMLContent)
ReDim Preserve mxtReunions(mNbReunions)
With mxtReunions(mNbReunions)
.Nom = oMatch.submatches(0)
.Ciel = oMatch.submatches(1)
.Temperature = oMatch.submatches(2)
.VitesseVent = oMatch.submatches(3)
.DirectionVent = oMatch.submatches(4)
End With
LoadCourses oMatch.submatches(5), mxtReunions(mNbReunions)
mNbReunions = mNbReunions + 1
Next oMatch
End With
End Sub
Private Sub LoadCourses(ByRef vsHTMLContent As String, ByRef vtReunion As Reunion)
Dim oMatch As Object
With CreateObject("VbScript.RegExp")
.Pattern = "Course \d+ : (.+?)\r[\s\S]*?(\d+H\d+),[\s\S]*?(<table[\s\S]+?</table>)[\s\S]+?(\d+:\d+)"
.Global = True
.MultiLine = True
For Each oMatch In .Execute(vsHTMLContent)
ReDim Preserve vtReunion.Courses(vtReunion.NbCourses)
With vtReunion.Courses(vtReunion.NbCourses)
.Nom = oMatch.submatches(0)
If IsDate(oMatch.submatches(1)) Then
.HeureCourse = CDate(oMatch.submatches(1))
Else
.HeureCourse = CDate(Replace(oMatch.submatches(1), "H", ":"))
End If
If IsDate(oMatch.submatches(3)) Then
.HeureReleve = CDate(oMatch.submatches(3))
End If
End With
LoadPartipations oMatch.submatches(2), vtReunion.Courses(vtReunion.NbCourses)
vtReunion.NbCourses = vtReunion.NbCourses + 1
Next oMatch
End With
End Sub
Private Sub LoadPartipations(ByRef vsHTMLContent As String, ByRef vtCourse As Course)
Dim oMatches As Object
Dim i As Long
With CreateObject("VbScript.RegExp")
.Pattern = "<td class=""(.*?)"".*?>[\s\S]*?([\w,]+)"
.Global = True
.MultiLine = True
Set oMatches = .Execute(vsHTMLContent)
For i = 0 To oMatches.Count \ 2 - 1
ReDim Preserve vtCourse.Participants(vtCourse.NbParticipants)
vtCourse.Participants(vtCourse.NbParticipants).NumID = oMatches(i).submatches(1)
vtCourse.NbParticipants = vtCourse.NbParticipants + 1
Next i
For i = i To oMatches.Count - 1
With vtCourse.Participants(i - vtCourse.NbParticipants)
.Favori oMatches(i).submatches(0) "fav"
.Partant = oMatches(i).submatches(1) <> "NP"
If IsNumeric(oMatches(i).submatches(1)) Then
.Cote = oMatches(i).submatches(1)
Else
.Cote = Val(oMatches(i).submatches(1))
End If
End With
Next i
End With
End Sub
marty14
Messages postés104Date d'inscriptionlundi 21 août 2006StatutMembreDernière intervention29 mai 2011 1 juil. 2009 à 13:27
Tres bien merci beaucoup.
Mais peus tu m"expliquer comment cela fonctionne, je ne sais absolument pas ce qu'est un regexp.
Dois mettre ce code dans un module ?
marty14
Messages postés104Date d'inscriptionlundi 21 août 2006StatutMembreDernière intervention29 mai 2011 1 juil. 2009 à 14:06
Je vient de créer un nouveau projet et mis tous le code sur la form avec une copie de la page html sur C :
Le programme demare mais ne se passe , j'ai une form vide a l'ecran!
1- Ensuite comment faire pour que ce programme aille chercher la page directement sur une url et non sur un C: ?
2- ou dois je inserer mon code de recherche :
For i = 1 To 10 Step 2
S = InStr(1, gg, "Réunion 2")
S = InStr(S, gg, "Course " & i & " :")
If S Then
Beep
P = InStr(S + 1, gg, "Course " & i + 1 & " :")
If P False Then P InStr(i + 1, gg, "Réunion 3")
Text11.Text = Mid(gg, S, P - (S))
End If
If InStr(1, Text11.Text, (" 1,1 ")) Then MsgBox "bravo"
If (Exists(" 14 partants ") Or Exists(" 15 partants ") Or Exists(" 16 partants ") Or Exists(" 17 partants ") Or Exists(" 18 partants ") Or Exists(" 19 partants ") Or Exists(" 20 partants ")) _
And _
(Exists(" 1,6 ") Or Exists(" 1,5 ") Or Exists(" 1,4 ") Or Exists(" 1,3 ") Or Exists(" 1,2 ") Or Exists(" 1,1 ")) Then
MsgBox "bravo"
Beep
End If
Next i
Je m'excuse de toute ses questions mais j'ai un peu de mal a comprendre.