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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
| Private Sub LinkLabel1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkLabel1.Click
'nécéssite d'activer la référence Microsoft HTML Objects Library
'nécéssite d'activer la référence Microsoft Internet Controls
Dim i, j, k As Integer
Dim IE As SHDocVw.InternetExplorer
Dim maPageHtml As MSHTML.HTMLDocument
Dim Helem As MSHTML.IHTMLElementCollection
Dim Pourcent1, PourcentN, Pourcent2 As Double
Dim Htable As MSHTML.IHTMLElementCollection
Dim maTable As MSHTML.IHTMLTable
Dim TblGame(0, 0) As String
Dim StopWatch As System.Diagnostics.Stopwatch
StopWatch = New Stopwatch
StopWatch.Start()
'1.On fait patienter
'LinkLabel1.Cursor = Cursors.WaitCursor
'2.On ouvre la page internet "http://www.pronosoft.com/fr/concours/repartition_lotofoot_7.php"
'qui contient la répartition
IE = CreateObject("internetExplorer.Application")
IE.Visible = False
IE.Navigate("http://www.pronosoft.com/fr/concours/repartition_lotofoot_7.php")
' System.Diagnostics.Process.Start("chrome.exe", "http://www.pronosoft.com/fr/concours/repartition_lotofoot_7.php")
'3.On attends le chargement complet de notre page internet
Do Until IE.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
Loop
'4.On commence par récupérer le n° et la date du LotoFoot7
maPageHtml = IE.Document
Helem = maPageHtml.getElementsByTagName("option")
For i = 0 To Helem.length - 1
If Helem(i).getAttribute("selected") = True Then
'idLF7 = Helem(i).value
LblGrilleNum.Text = Helem(i).innerText 'Grille n° XXX du XX/XX/2015
Exit For
End If
Next
'5.On libère les variables qui ne sont plus necessaires : Helem
Helem = Nothing
'6.On récupère le n° des matchs , le nom des équipes et la répartition dans TblGame
' objet type table
Htable = maPageHtml.getElementsByTagName("table")
' tableau dans la page Web contenant le n° des matchs , le nom des équipes et la répartition
maTable = Htable(3)
ReDim TblGame(7, 5)
' boucle sur toutes les lignes du tableau
For j = 1 To maTable.rows.length - 2
'boucle sur les cellules dans chaque ligne
For k = 1 To maTable.rows(j - 1).Cells.Length
TblGame(j - 1, k - 1) = maTable.rows(j - 1).Cells(k - 1).innerText
Next k
Next j
'le nom des équipes
LblTeamA.Text = TblGame(1, 1).ToString
LblTeamB.Text = TblGame(1, 2).ToString
LblTeamC.Text = TblGame(2, 1).ToString
LblTeamD.Text = TblGame(2, 2).ToString
LblTeamE.Text = TblGame(3, 1).ToString
LblTeamF.Text = TblGame(3, 2).ToString
LblTeamG.Text = TblGame(4, 1).ToString
LblTeamH.Text = TblGame(4, 2).ToString
LblTeamI.Text = TblGame(5, 1).ToString
LblTeamJ.Text = TblGame(5, 2).ToString
LblTeamK.Text = TblGame(6, 1).ToString
LblTeamL.Text = TblGame(6, 2).ToString
LblTeamM.Text = TblGame(7, 1).ToString
LblTeamN.Text = TblGame(7, 2).ToString
'la répartition
Dim m As Integer
Dim n As Integer = 0
Dim TblBase(6) As Double
For m = 1 To 7
'Pour comparer les pourcentages : Remplacement des % par des espaces puis
'supression des espaces à gauche et à droite
Pourcent1 = CDbl(Trim(Replace(TblGame(m, 3).ToString, "%", "")))
PourcentN = CDbl(Trim(Replace(TblGame(m, 4).ToString, "%", "")))
Pourcent2 = CDbl(Trim(Replace(TblGame(m, 5).ToString, "%", "")))
If Pourcent1 > PourcentN And Pourcent1 > Pourcent2 Then
TblChoix(n) = "X"
Répartition = Répartition & "1"
TblBase(m - 1) = Pourcent1
ElseIf PourcentN > Pourcent1 And PourcentN > Pourcent2 Then
TblChoix(n + 1) = "X"
Répartition = Répartition & "N"
TblBase(m - 1) = PourcentN
ElseIf Pourcent2 > Pourcent1 And Pourcent2 > PourcentN Then
TblChoix(n + 2) = "X"
Répartition = Répartition & "2"
TblBase(m - 1) = Pourcent2
End If
n = n + 3
Next m
Dim Max As Double
Max = TblBase(0)
Base = 1
For i = 1 To TblBase.GetUpperBound(0)
If TblBase(i) > Max Then
Max = TblBase(i)
Base = Base + 1
End If
Next i
For Each ctrl As Control In GroupBox1.Controls
If ctrl.GetType Is GetType(Label) Then
If ctrl.Text = Base.ToString Then
ctrl.Text = "B"
ctrl.ForeColor = Color.White
ctrl.BackColor = Color.FromArgb(255, 128, 0)
ctrl.Font = New System.Drawing.Font("Microsoft Sans Serif", 11, FontStyle.Bold)
Exit For
End If
End If
Next
Array.Sort(TblBase)
'5.On libère les variables qui ne sont plus necessaires : Helem
Helem = Nothing
Htable = Nothing
maTable = Nothing
TblGame(7, 5) = Nothing
n = 0
IE.Quit()
'LinkLabel1.Cursor = Cursors.Default
LinkLabel1.LinkVisited = True
LinkLabel1.LinkColor = Color.Teal
Call Tableau_To_RadioButton(Panel1)
Call Synthèse() ' mise à jour de la synthèse
' Activation des filtres
BtnAucun.Enabled = True
BtnNiv1.Enabled = True
BtnNiv2.Enabled = True
BtnNiv3.Enabled = True
'LinkLabel1.Enabled = False
StopWatch.Stop()
MsgBox("Execution time in seconds: " + CStr(StopWatch.Elapsed.TotalSeconds))
End Sub |
Partager