title: Caesar Cipher encryption VB.net
body: <p>I am trying to make an encryption method in VB.net.<br />
  I plan to use arrays so you input the value and it then compares two arrays changing the value.</p>
  <pre><code>    Console.WriteLine(&quot;Please input text&quot;)
      Dim UserInput As String = Console.ReadLine
      UserInput = UserInput.ToUpper()
      Console.WriteLine(&quot;Original Input is &quot; &amp; UserInput)
  
      Dim EncriptedText As String
      Dim Numbers() As String = {&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;}
      Dim Letters() As String = {&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;, &quot;F&quot;, &quot;G&quot;, &quot;H&quot;, &quot;I&quot;, &quot;J&quot;, &quot;K&quot;, &quot;L&quot;, &quot;M&quot;, &quot;N&quot;, &quot;O&quot;, &quot;P&quot;, &quot;Q&quot;, &quot;R&quot;, &quot;S&quot;, &quot;T&quot;, &quot;U&quot;, &quot;V&quot;, &quot;W&quot;, &quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;, &quot; &quot;}
  
  
      For counter As Integer = 0 To UserInput.Length - 1
          Dim pos As Integer = Array.IndexOf(Numbers, UserInput.Chars(counter))
          Dim CharValue As Char = Letters.ElementAt(pos)
          UserInput = UserInput + CharValue
          Console.WriteLine(UserInput)
      Next
  
      Console.Read()
  End Sub
  </code></pre>
  <p>It throws an error when I try to run it.<br />
  Does anyone have any idea how I could fix it?</p>
  <blockquote>
  <p>Error : Found on The Dim CharValue As Char Line</p>
  <p>An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
  Additional information: Index was out of range. Must be non-negative and less than the size of the collection.</p>
  </blockquote>
  <p>I was thinking it could be because I am trying to convert numbers to chars and if so what other methods could I use?</p>