You will find that most problems in programming can be solved in many ways. One of them will be the best, but often several ways will be almost equally good. Some ways will definitely be the wrong way, although they might still work.
How do we analyze for example 4 values ? How initialize variables in sub routine ?
Here is an example that answers those question, but it is not a good example and is probably not the best way to do this task.
Sub Example(n As Int) As String
Dim result As String ' Create a variable inside subroutine
If (n = 1) Then result = "X"
If (n = 2) Then result = "Y"
If (n = 3) Then result = "Z"
If (n = 4) Then result = "!"
Return result
End Sub
Here is another example that does the same job; again it is not a good example ...
Sub anotherExample(n As Int) As String
Dim letters As List ' Create a list
letters.initialize ' Initialise it
letters.Add("X") ' Add some content
letters.Add("Y")
letters.Add("Z")
letters.Add("!")
Return letters.Get(n - 1)
End Sub
In this case the better way would be to create the list once, outside the subroutine, rather than create it again every time that you need to use the subroutine. Also there are often more direct ways of converting numbers to characters if the characters are in a continuous series.
Also I find that the examples of the manual are short.
Yes - that is because they are just examples. If you want to learn programming you need to look aat many examples and learn the basic skills before you try to start writing a complete program.