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
| Sub CodePeriodicite()
Dim StrmRdr = New StreamReader(Main.Path & "Monfichier.txt", System.Text.Encoding.Default)
Str = StrmRdr.ReadToEnd()
StrmRdr.Close()
Dim StrTemp As String = ""
For A As Int32 = 0 To DGV.Rows.Count-1
StrTemp = DGV("Code Titre", A).Value
'Le code titre est en longueur fixe sur 6 caractères :
If Len(StrTemp) <> 6 Then
StrTemp &= " "
Else
StrTemp &= ";"
End If
Dim RgExp As New Regex("1;0;" & StrTemp & "[^\r\n]+")
Dim MtcColl As MatchCollection = RgExp.Matches(Str)
Dim Mtc As Match
For Each Mtc In MtcColl
SubChaine = Mtc.Value.Split(";")
DGV("Code Périodicité", A).Value = SubChaine(6)
Exit For
Next
Next
End Sub |
Partager