Compteur de lettres

jifip Messages postés 1 Date d'inscription dimanche 23 mai 2004 Statut Membre Dernière intervention 23 mai 2004 - 23 mai 2004 à 22:00
cs_chris81 Messages postés 589 Date d'inscription jeudi 2 octobre 2003 Statut Membre Dernière intervention 29 avril 2008 - 24 mai 2004 à 13:21
Bonsoir,
je cherche à créer une fonction qui, à partir d'un texte sous word, me renvoie le nombre de chaque lettre, de chaque chiffre, d'espaces qui s'y trouvent...

Merci pour votre aide

valy

2 réponses

cs_chris81 Messages postés 589 Date d'inscription jeudi 2 octobre 2003 Statut Membre Dernière intervention 29 avril 2008 2
24 mai 2004 à 12:51
sous vb net tu fais un streamreader qui lit ton fichier et qui compte

while Streamreader.peek >0 'tu lis
TaLettre = streamreader.peek ou read
si numeric
CountNumeris= CountNumeric +1
sinon
CountAlpha = CountAlpha +1

si Streamreader.peek=0 'Espace
CountEspace= CountEspace+1
fin si
fin si
0
cs_chris81 Messages postés 589 Date d'inscription jeudi 2 octobre 2003 Statut Membre Dernière intervention 29 avril 2008 2
24 mai 2004 à 13:21
voici quelque chose pour t'aider a demarrer

Dim Lecteur As New StreamReader("C:\FR.txt")
Dim CaractereLu As String
Dim CountNum, CountAlpha, CountEspace As Integer
Dim i As Integer

CaractereLu = Lecteur.ReadLine

Dim tab(CaractereLu.Length) As String

For i = 1 To CaractereLu.Length
tab(i) = Mid(CaractereLu, i, 1)
Next

For i = 1 To CaractereLu.Length

If IsNumeric(tab(i)) Then
CountNum = CountNum + 1
End If

If Not IsNumeric(tab(i)) Then
CountAlpha = CountAlpha + 1
End If

If tab(i) = "" Then
CountEspace = CountEspace + 1
End If

Next

Label3.Text = CountNum
Label4.Text = CountAlpha
Label5.Text = CountEspace
0
Rejoignez-nous