I am trying to make a substitution cipher solver in vb.net but whenever I try to solve a cipher text using methods other than shift it goes back to the original. This is the code I have so far
does anyone have any suggestions
as you can see from the attachments when I press solve it goes back to the original text
Code:
Dim Ctl As Control, nAsc As Int16
For Each Ctl In Panel2.Controls
If TypeOf (Ctl) Is TextBox Then
nAsc = Asc(Microsoft.VisualBasic.Left(Ctl.Name, 1))
If Reverse.Checked = False Then
nAsc = nAsc + Shift.Value
Else
nAsc = 90 - nAsc + 65 + Shift.Value
End If
If nAsc > 90 Then nAsc = nAsc - 26
If nAsc < 65 Then nAsc = nAsc + 26
Ctl.Text = Chr(nAsc)
End If
Next
SolutionSubstitution.Text = EncryptionSubstitution.Text
Dim sourceChar As Char
For Each Ctl In Panel2.Controls
If TypeOf (Ctl) Is TextBox Then
sourceChar = Microsoft.VisualBasic.Left(Ctl.Name, 1)
SolutionSubstitution.Text = SolutionSubstitution.Text.Replace(sourceChar, Chr(Asc(Ctl.Text) + 128))
End If
Next
For Each Ctl In Panel2.Controls
If TypeOf (Ctl) Is TextBox Then
sourceChar = Chr(Asc(Microsoft.VisualBasic.Left(Ctl.Name, 1)) + 128)
SolutionSubstitution.Text = SolutionSubstitution.Text.Replace(sourceChar, Microsoft.VisualBasic.Left(Ctl.Name, 1))
End If
Next
as you can see from the attachments when I press solve it goes back to the original text