Question: I'm trying to shift letters to the end of the word. Like the sample output I have in the image.
[![Sample output](https://i.stack.imgur.com/BofY1.png)](https://i.stack.imgur.com/BofY1.png)
Using getchar and remove function, I was able to shift 1 letter. 

```
        mychar = GetChar(word, 1)   'Get the first character
        word = word.Remove(0, 1)  'Remove the first character
        input.Text = mychar         
        word = word & mychar
        output.Text = word

```

This is my code for shifting 1 letter.
I.E. for the word 'Star Wars', it currently shifts 1 letter, and says 'tar WarsS'

How can I make this move 3 characters to the end? Like in the sample image.

Answer: 
You could write a that as a sort of permute, which maps each char-index to a new place in the range `[0, textLength[`

In order to do that you'll have to write a custom modulus as the `Mod` operator is more a remainder than a modulus (from a mathematical point of view, regarding how negative are handled)

With that you just need to loop over your string indexes and map each one to it's "offsetted" value modulo the length of the text

```
' Can be made local to Shift method if needed
Function Modulus(dividend As Integer, divisor As Integer) As Integer
    dividend = dividend Mod divisor
    Return If(dividend < 0, dividend + divisor, dividend)
End Function

Function Shift(text As String, offset As Integer) As String
    ' validation omitted
    Dim length = text.Length
    Dim arr(length - 1) As Char

    For i = 0 To length - 1
        arr(Modulus(i + offset, length) Mod length) = text(i)
    Next

    Return new String(arr)
End Function

```

That way you can easily handle negative values or values greater than the length of the text.

Note, the same thing is possible with a `StringBuilder` instead of an array ; I'm not sure which one is "better"

```
Function Shift(text As String, offset As Integer) As String
    Dim builder As New StringBuilder(text)
    Dim length = text.Length

    For i = 0 To length - 1
        builder(Modulus(i + offset, length) Mod length) = text(i)
    Next

    Return builder.ToString
End Function

```
```
n = 3
output.Text = Right(word, Len(word) - n) & Left(word, n)

```