|
Public Class Form1
Dim dopo As Object
Dim risultato As Integer
Dim numero As Object
Dim num, somma, con, con1, diff, rot As Integer
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"}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtinput.Text = "prova"
TextBox1.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
txtinput.Text = ""
txtoutput.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo errore
txtoutput.Clear()
dopo = Len(txtinput.Text)
If IsNumeric(TextBox1.Text) Then
rot = CInt(TextBox1.Text)
txtinput.Text.ToLower()
For Each car In txtinput.Text
If lett.Contains(car) Then
num = Asc(car)
somma = num
For Me.con = 1 To rot
somma += 1
If somma > 122 Then
diff = rot - con
somma = 97
End If
Next
txtoutput.AppendText(Chr(somma))
Else
txtoutput.AppendText(car)
End If
Next
Else
MsgBox("inserisci un numero nella casella di testo")
TextBox1.Focus()
End If
Exit Sub
errore:
If TextBox1.Text = "" Then
MsgBox("inserisci un numero nella casella di testo")
TextBox1.Focus()
Else
MsgBox("hai causato l'errore N. " & CStr(Err. Number) & " " & Err. Description, vbRetryCancel + vbCritical, "errore")
If risultato = MsgBoxResult.Ok Then
txtinput.Focus()
Else
End
End If
End If
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
On Error GoTo errore
txtinput.Text = txtoutput.Text
txtoutput.Clear()
dopo = Len(txtinput.Text)
If IsNumeric(TextBox1.Text) Then
rot = CInt(TextBox1.Text)
txtinput.Text.ToLower()
For Each car In txtinput.Text
If lett.Contains(car) Then
num = Asc(car)
somma = num
For Me.con = 1 To rot
somma = somma - 1
If somma < 97 Then
diff = rot - con
somma = 122
End If
Next
txtoutput.AppendText(Chr(somma))
Else
txtoutput.AppendText(car)
End If
Next
Else
MsgBox("inserisci un numero nella casella di testo")
TextBox1.Focus()
End If
Exit Sub
errore:
Else
If TextBox1.Text = "" Then
MsgBox("inserisci un numero nella casella di testo")
Else
MsgBox("hai causato l'errore N. " & CStr(Err. Number) & " " & Err. Description, vbRetryCancel + vbCritical, "errore")
If risultato = MsgBoxResult.Retry Then
txtinput.Focus()
Else
End
End If
End If
End If
End Sub
End Class
|
|