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
| Dim i As Integer, j As Integer
Dim debutbloc As Integer
Dim flagdep As Boolean
Dim flagfin As Boolean
Dim distance As Single
Dim vitesse() As Single
Dim td() As Integer
Dim tf() As Integer
Dim temps As Single
Dim temps1 As Single
Dim temps2 As Single
Dim valeur As String
Dim indice As Integer ' pour le tableau des vitesses
Dim tdep, tfin As Single
Liste.AddItem "10"
Liste.AddItem "0"
Liste.AddItem "0"
Liste.AddItem "0"
Liste.AddItem "100"
Liste.AddItem "120"
Liste.AddItem "150"
Liste.AddItem "0"
Liste.AddItem "0"
Liste.AddItem "0"
Liste.AddItem "250"
Liste.AddItem "260"
listdistance.AddItem "25,07"
listdistance.AddItem "3,74"
listdistance.AddItem "3,74"
listdistance.AddItem "22,20"
listdistance.AddItem "4,90"
listdistance.AddItem "6,71"
listdistance.AddItem "7,14"
listdistance.AddItem "10,34"
listdistance.AddItem "10,44"
listdistance.AddItem "7,55"
listdistance.AddItem "5,39"
debutbloc = 0
ReDim vitesse(0)
ReDim td(0)
ReDim tf(0)
indice = 0
Do
flagdep = False
distance = 0
For i = debutbloc To Liste.ListCount - 1
' on cherche tdep
DoEvents
If Val(Liste.List(i)) = 0 And i > 0 Then
tdep = Liste.List(i - 1)
distance = distance + Val(listdistance.List(i - 1)) ' on ajoute la première distance
flagdep = True
td(indice) = i - 1
Exit For
End If
Next i
' on cherche tfin
If flagdep = True Then ' si tdep trouvé on cherché tfin
flagfin = False
For j = i + 1 To Liste.ListCount - 1
distance = distance + Val(listdistance.List(j - 1)) ' on rajoute les suivantes
DoEvents
If Val(Liste.List(j)) <> 0 Then
tfin = Liste.List(j)
flagfin = True
tf(indice) = j
Exit For
End If
Next j
End If
If flagdep = False Then Exit Do
' on calcule la vitesse
temps = CSng(Liste.List(tf(indice))) - CSng(Liste.List(td(indice)))
vitesse(indice) = distance / temps
'listvitesse.AddItem str$(vitesse(indice))
indice = indice + 1
ReDim Preserve vitesse(0 To indice)
ReDim Preserve td(0 To indice)
ReDim Preserve tf(0 To indice)
debutbloc = j + 1
If debutbloc > Liste.ListCount - 1 Then Exit Do
Loop
ReDim Preserve vitesse(0 To indice - 1)
ReDim Preserve td(0 To indice - 1)
ReDim Preserve tf(0 To indice - 1)
For i = 0 To UBound(vitesse)
For j = td(i) + 1 To tf(i) - 1
temps1 = CSng(Liste.List(j - 1))
temps2 = CSng(listdistance.List(j - 1)) / vitesse(i)
temps = temps1 + temps2
Liste.List(j) = Replace(temps, ".", ",")
Next j
Next i |
Partager