Statistique

Contenu du snippet

Enfin, un programme qui calcule les fréquences d'apparitions des caractères au sein d'un texte.
ça permet de trouver des messages codés grâce à un substion alphabétique.

Voilà

Source / Exemple :


Private Sub Command1_Click()
Dim chaine As String
Dim test As String
Dim ia
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
Dim esp

chaine = Text1
chaine = Trim(LCase(chaine))
For ia = 1 To Len(chaine)
test = Mid(chaine, ia, 1)
    Select Case test
    Case "a"
    a = a + 1: Case "b": b = b + 1: Case "c": c = c + 1: Case "d": d = d + 1
    Case "e": e = e + 1: Case "f": f = f + 1: Case "g": g = g + 1: Case "h"
    h = h + 1: Case "i": i = i + 1: Case "j": j = j + 1: Case "k": k = k + 1
    Case "l": l = l + 1: Case "m": m = m + 1: Case "n": n = n + 1: Case "o"
    o = o + 1: Case "p": p = p + 1: Case "q": q = q + 1: Case "r": r = r + 1
    Case "s": s = s + 1: Case "t": t = t + 1: Case "u": u = u + 1: Case "v"
    v = v + 1: Case "w": w = w + 1: Case "x": x = x + 1: Case "y": y = y + 1
    Case "z": z = z + 1
    Case Else
    esp = esp + 1
    End Select
Next
effectif = (Len(chaine) - esp)
a = a * 100 / effectif: b = b * 100 / effectif: c = c * 100 / effectif: d = d * 100 / effectif: e = e * 100 / effectif: f = f * 100 / effectif: g = g * 100 / effectif: h = h * 100 / effectif: i = i * 100 / effectif: j = j * 100 / effectif: k = k * 100 / effectif: l = l * 100 / effectif: m = m * 100 / effectif: n = n * 100 / effectif: o = o * 100 / effectif: p = p * 100 / effectif: q = q * 100 / effectif: r = r * 100 / effectif: s = s * 100 / effectif: t = t * 100 / effectif: u = u * 100 / effectif: v = v * 100 / effectif: w = w * 100 / effectif: x = x * 100 / effectif: y = y * 100 / effectif: z = z * 100 / effectif
Text2 = Round(a, 1): Text3 = Round(b, 1): Text4 = Round(c, 1): Text5 = Round(d, 1): Text6 = Round(e, 1): Text7 = Round(f, 1): Text8 = Round(g, 1): Text9 = Round(h, 1): Text10 = Round(i, 1): Text11 = Round(j, 1): Text12 = Round(k, 1): Text13 = Round(l, 1): Text14 = Round(m, 1): Text15 = Round(n, 1): Text16 = Round(o, 1): Text17 = Round(p, 1): Text18 = Round(q, 1): Text19 = Round(r, 1): Text20 = Round(s, 1): Text21 = Round(t, 1): Text22 = Round(u, 1): Text23 = Round(v, 1): Text24 = Round(w, 1): Text25 = Round(x, 1): Text26 = Round(y, 1): Text27 = Round(z, 1)
End Sub

Private Sub mnuquit_Click()
Unload Form1
End Sub

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.