Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Ecrire un fichier avec 3 lignes comportant respectivement 1, 2 et 3 tabs Dim texte As String = Chr(9) & "1 tab" & vbCrLf & Chr(9) & Chr(9) & "2 tabs" & vbCrLf & Chr(9) & Chr(9) & Chr(9) & "3 tabs" System.IO.File.WriteAllText(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\test.txt", texte) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Lire le fichier et compter les tabs pour chaque ligne Dim texte As String() = System.IO.File.ReadAllLines(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\test.txt") Dim resultat As String = "" Dim numeroLigne As Integer = 0 For Each item As String In texte Dim position As Integer = 0 Dim caractere As String = "" numeroLigne += 1 Do caractere = item.Substring(position, 1) If caractere = Chr(9) Then position += 1 Loop Until caractere <> Chr(9) resultat &= "Nombre de tabs dans la ligne " & numeroLigne.ToString & " : " & position.ToString & vbCrLf Next MessageBox.Show(resultat) End Sub