Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
crittografo - Form1.vb

Form1.vb

Caricato da: Walker93
Scarica il programma completo

  1. Public Class Form1
  2.     Dim dopo As Object
  3.     Dim risultato As Integer
  4.     Dim numero As Object
  5.     Dim num, somma, con, con1, diff, rot As Integer
  6.     Dim lett() As String = {"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", "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"}
  7.  
  8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  9.         txtinput.Text = "prova"
  10.         TextBox1.Focus()
  11.     End Sub
  12.  
  13.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  14.         End
  15.     End Sub
  16.  
  17.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  18.         txtinput.Text = ""
  19.         txtoutput.Text = ""
  20.     End Sub
  21.  
  22.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  23.         On Error GoTo errore
  24.         txtoutput.Clear()
  25.         dopo = Len(txtinput.Text)
  26.         If IsNumeric(TextBox1.Text) Then
  27.             rot = CInt(TextBox1.Text)
  28.             txtinput.Text.ToLower()
  29.  
  30.             For Each car In txtinput.Text
  31.                 If lett.Contains(car) Then
  32.                     num = Asc(car)
  33.                     somma = num
  34.                     For Me.con = 1 To rot
  35.                         somma += 1
  36.                         If somma > 122 Then
  37.                             diff = rot - con
  38.                             somma = 97
  39.                         End If
  40.                     Next
  41.                     txtoutput.AppendText(Chr(somma))
  42.                 Else
  43.                     txtoutput.AppendText(car)
  44.                 End If
  45.             Next
  46.         Else
  47.             MsgBox("inserisci un numero nella casella di testo")
  48.             TextBox1.Focus()
  49.         End If
  50.         Exit Sub
  51. errore:
  52.         If TextBox1.Text = "" Then
  53.             MsgBox("inserisci un numero nella casella di testo")
  54.             TextBox1.Focus()
  55.         Else
  56.  
  57.             If Err.Number <> 0 Then
  58.                 MsgBox("hai causato l'errore N. " & CStr(Err.Number) & " " & Err.Description, vbRetryCancel + vbCritical, "errore")
  59.                 If risultato = MsgBoxResult.Ok Then
  60.                     txtinput.Focus()
  61.                 Else
  62.                     End
  63.                 End If
  64.             End If
  65.         End If
  66.     End Sub
  67.  
  68.  
  69.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  70.         On Error GoTo errore
  71.         txtinput.Text = txtoutput.Text
  72.         txtoutput.Clear()
  73.         dopo = Len(txtinput.Text)
  74.         If IsNumeric(TextBox1.Text) Then
  75.             rot = CInt(TextBox1.Text)
  76.             txtinput.Text.ToLower()
  77.             For Each car In txtinput.Text
  78.                 If lett.Contains(car) Then
  79.                     num = Asc(car)
  80.                     somma = num
  81.                     For Me.con = 1 To rot
  82.                         somma = somma - 1
  83.                         If somma < 97 Then
  84.                             diff = rot - con
  85.                             somma = 122
  86.                         End If
  87.                     Next
  88.                     txtoutput.AppendText(Chr(somma))
  89.                 Else
  90.                     txtoutput.AppendText(car)
  91.                 End If
  92.             Next
  93.         Else
  94.             MsgBox("inserisci un numero nella casella di testo")
  95.             TextBox1.Focus()
  96.         End If
  97.         Exit Sub
  98. errore:
  99.         If Err.Number = 0 Then
  100.         Else
  101.             If TextBox1.Text = "" Then
  102.                 MsgBox("inserisci un numero nella casella di testo")
  103.             Else
  104.                 MsgBox("hai causato l'errore N. " & CStr(Err.Number) & " " & Err.Description, vbRetryCancel + vbCritical, "errore")
  105.                 If risultato = MsgBoxResult.Retry Then
  106.                     txtinput.Focus()
  107.                 Else
  108.                     End
  109.                 End If
  110.             End If
  111.         End If
  112.     End Sub
  113. End Class