Vba excel chiffrement de Vigenère

Résolu
Pierre_4247 Messages postés 9 Statut Membre -  
Pierre_4247 Messages postés 9 Statut Membre -

Bonjour,
je dois créer un code en VBA Excel pour effectuer un chiffrement de Vigenère, pour obtenir le résultat de la photo ci-jointe.

J'ai commencé mais je suis bloqué, pouvez-vous m'aider à compléter voire modifier mon code VBA.
Mon programme : https://www.cjoint.com/c/JLivDXFm4iR

Merci d'avance

Configuration: Windows / Chrome 87.0.4280.88

2 réponses

  1. via55 Messages postés 14393 Date d'inscription   Statut Membre Dernière intervention   2 759
     
    Bonjour Pierre

    A mon avis le code pourrait se réduire à cela :
    Sub Bouton1_Cliquer()
    
    Dim txt As String, key As String
    txt = Cells(2, 2)
    key = Cells(3, 2)
    
    For i = 1 To Len(txt)
    
        Cells(i + 5, 2) = Mid(txt, i, 1)
        a = Asc(Cells(i + 5, 2)) - 64
        x = x + 1
        If x > Len(key) Then x = 1
        Cells(i + 5, 3).Value = Mid(key, x, 1)
        b = Asc(Cells(i + 5, 3)) - 64
        c = a + b
        If c > 26 Then c = c - 26
        Cells(i + 5, 4).Value = Chr(c + 63)
        
    Next i
            
    End Sub

    Cdlmnt
    Via
    0
  2. Pierre_4247 Messages postés 9 Statut Membre
     
    Nikel, merci !
    0