nair17
Messages postés28Date d'inscriptionlundi 12 janvier 2009StatutMembreDernière intervention29 juin 2009
-
12 janv. 2009 à 11:24
nair17
Messages postés28Date d'inscriptionlundi 12 janvier 2009StatutMembreDernière intervention29 juin 2009
-
12 janv. 2009 à 17:52
Bonjour, voila je fais un programme et j'aimerais que quand j'écris un mot dans un textbox et je clique sur le boutton "décomposition d'un mot" alors il s'affiche dans un inputbox la décomposition du mot et combien de fois il aparait
exemple:
J'écris dans mon textbox : programme
je clique sur boutton"décomposition d'un mot" et il s'affiche dans l'inputbox:
p apparait 1fois
r apparrait 2fois
o apparrait 1fois
a apparait 1fois
m apparait 2fois
e apparait 1fois
Function GetCharsCount(ByVal sText As String, Optional ByVal bUcase As Boolean = False) As Int32()
Dim aiRet(0 To 255) As Int32
If sText.Length > 0 Then
If bUcase Then sText = sText.ToUpper
Dim abChars() As Char = sText.ToCharArray
For i As Int32 = 0 To sText.Length - 1
aiRet(Convert.ToByte(abChars(i))) += 1
Next
End If
Return aiRet
End Function
'=====================
'EXEMPLE D'UTILISATION
'=====================
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
Dim aiChars() As Int32 = GetCharsCount(TextBox1.Text, True)
For i As Int32 = 0 To 255
If aiChars(i) > 0 Then ListBox1.Items.Add(Convert.ToChar(i) & " " & aiChars(i).ToString)
Next
End Sub
<hr size="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
PCPT
Messages postés13280Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201849 12 janv. 2009 à 13:32
à toi d'adapter ensuite, le résultat "affiché" n'est qu'un exemple
en msgbox il te suffit de concaténer une chaine
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim aiChars() As Int32 = GetCharsCount(TextBox1.Text, True)
Dim sRet As String = "Listing des lettres trouvées"
For i As Int32 = 0 To 255
If aiChars(i) > 0 Then sRet &= String.Format("{0}{1} {2}", Environment.NewLine, Convert.ToChar(i), aiChars(i).ToString)
Next
MessageBox.Show(sRet)
End Sub
<!-- Coloration syntaxique vb/vba/vb.net : http://charles.racaud.free.fr/code-syntaxing/ -->
Coloration syntaxique vb/vba/vb.net
<hr size="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp