Coder/décoder avec la font webdings

Contenu du snippet

-Créer des boutons de commande (9 en tout).
-2 RichTextBox nommés rtfCode et Text1
-Créer 2 contrôles ComonDialog nommé
dlgCommonDialog1 et dlgCommonDialog2

Source / Exemple :


Private Sub Command1_Click()
Text1.Text = ""
Text1.Text = rtfCode.Text
End Sub

Private Sub Command10_Click()
fraMDP.Visible = True
End Sub

Private Sub Command11_Click()
Dim mdpbon
mdpbon = Text2.Text = rtfMDP.Text
If mdpbon = False Then
  MsgBox "Vousn'avez pas confirmer le même mot de passe", , "Décodeur -- Mot de passe"
  Text2.SelText
End If

If mdpbon = True Then
  Dim sFile As String
        With dlgCommonDialog
            .DialogTitle = "Enregistrer le Mot de passe"
            .CancelError = False
            .Filter = "Fichiers Mot de passe (*.mdp)|*.mdp"
            .ShowSave
            If Len(.FileName) = 0 Then
                Exit Sub
            End If
            sFile = .FileName
        End With
        rtfMDP.SaveFile sFile
End If
End Sub

Private Sub Command12_Click()
fraMDP.Visible = False
End Sub

Private Sub Command2_Click()
rtfCode.Text = ""
rtfCode.Text = Text1.Text
End Sub

Private Sub Command3_Click()
    Dim sFile As String

    With dlgCommonDialog1
        .DialogTitle = "Ouvrir un texte codé"
        .CancelError = False
        .Filter = "Fichiers Codés (*.cod)|*.cod"
        .ShowOpen
        If Len(.FileName) = 0 Then
            Exit Sub
        End If
        sFile = .FileName
    End With
    rtfCode.LoadFile sFile
    lblCod.Caption = sFile
End Sub

Private Sub Command4_Click()
Dim sFile As String
        With dlgCommonDialog1
            .DialogTitle = "Enregistrer le texte codé"
            .CancelError = False
            .Filter = "Fichiers Codés (*.cod)|*.cod"
            .ShowSave
            If Len(.FileName) = 0 Then
                Exit Sub
            End If
            sFile = .FileName
        End With
        rtfCode.SaveFile sFile
    
        rtfCode.SaveFile sFile
        lblCod.Caption = sFile
End Sub

Private Sub Command5_Click()
    On Error Resume Next
    If frmDécod Is Nothing Then Exit Sub
    
    With dlgCommonDialog1
        .DialogTitle = "Imprimer le texte codé"
        .CancelError = True
        .Flags = cdlPDReturnDC + cdlPDNoPageNums
        If rtfCode.SelLength = 0 Then
            .Flags = .Flags + cdlPDAllPages
        Else
            .Flags = .Flags + cdlPDSelection
        End If
        .ShowPrinter
        If Err <> MSComDlg.cdlCancel Then
            rtfCode.SelPrint .hDC
        End If
    End With
End Sub

Private Sub Command6_Click()
'Ouvre le texte décodé

    Dim sFile As String

    With dlgCommonDialog2
        .DialogTitle = "Ouvrir un texte décodé"
        .CancelError = False
        .Filter = "Fichiers Texte (*.txt)|*.txt"
        .ShowOpen
        If Len(.FileName) = 0 Then
            Exit Sub
        End If
        sFile = .FileName
    End With
    Text1.LoadFile sFile
    lblDécod.Caption = sFile
End Sub

Private Sub Command7_Click()
'Enregistre le text1

Dim sFile As String
        With dlgCommonDialog2
            .DialogTitle = "Enregistrer le texte décodé"
            .CancelError = False
            .Filter = "Fichiers Texte (*.txt)|*.txt"
            .ShowSave
        If Len(.FileName) = 0 Then
              Exit Sub
        End If
            sFile = .FileName
        End With
        Text1.SaveFile sFile
    
       lblDécod.Caption = sFile
End Sub

Private Sub Command8_Click()
'Imprime le text1

    On Error Resume Next
    If frmDécod Is Nothing Then Exit Sub
    
    With dlgCommonDialog2
        .DialogTitle = "Imprimer le texte codé"
        .CancelError = True
        .Flags = cdlPDReturnDC + cdlPDNoPageNums
        If Text1.SelLength = 0 Then
            .Flags = .Flags + cdlPDAllPages
        Else
            .Flags = .Flags + cdlPDSelection
        End If
        .ShowPrinter
        If Err <> MSComDlg.cdlCancel Then
            Text.SelPrint .hDC
        End If
    End With
End Sub

Private Sub Command9_Click()
End
End Sub

Conclusion :


Un texte est écrit en Webdings (Une écriture "Codée") et transformée en texte normale. Vis-Verça.

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.