Option Explicit On 
Option Strict On

Public Class frmCode
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents txtWord As System.Windows.Forms.TextBox
  Friend WithEvents btnEncode As System.Windows.Forms.Button
  Friend WithEvents btnDecode As System.Windows.Forms.Button

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.txtWord = New System.Windows.Forms.TextBox()
    Me.btnEncode = New System.Windows.Forms.Button()
    Me.btnDecode = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'txtWord
    '
    Me.txtWord.Location = New System.Drawing.Point(24, 16)
    Me.txtWord.Name = "txtWord"
    Me.txtWord.Size = New System.Drawing.Size(232, 20)
    Me.txtWord.TabIndex = 0
    Me.txtWord.Text = ""
    '
    'btnEncode
    '
    Me.btnEncode.Location = New System.Drawing.Point(40, 48)
    Me.btnEncode.Name = "btnEncode"
    Me.btnEncode.TabIndex = 1
    Me.btnEncode.Text = "&Encode"
    '
    'btnDecode
    '
    Me.btnDecode.Location = New System.Drawing.Point(168, 48)
    Me.btnDecode.Name = "btnDecode"
    Me.btnDecode.TabIndex = 2
    Me.btnDecode.Text = "&Decode"
    '
    'frmCode
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(284, 97)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnDecode, Me.btnEncode, Me.txtWord})
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmCode"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Code Problem"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub btnEncode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncode.Click
    Dim I As Integer
    Dim Word1 As String, Word2 As String
    'Read typed word - initialize encoded word
    Word1 = txtWord.Text
    Word2 = ""
    'Find ASCII representation for each character and subtract 1
    For I = 1 To Len(Word1)
      Word2 = Word2 + Chr(Asc(Mid(Word1, I, 1)) - 1)
    Next I
    'Display encoded word
    txtWord.Text = Word2
  End Sub

  Private Sub btnDecode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecode.Click
    Dim I As Integer
    Dim Word1 As String, Word2 As String
    'Read typed word - initialize decoded word
    Word1 = txtWord.Text
    Word2 = ""
    'Find ASCII representation for each character and add 1
    For I = 1 To Len(Word1)
      Word2 = Word2 + Chr(Asc(Mid(Word1, I, 1)) + 1)
    Next I
    'Display encoded word
    txtWord.Text = Word2
  End Sub
End Class
