Small Basic: Generating a Random Character

To generate a random character between A and Z, you can write this code:

code = 64 + Math.GetRandomNumber(26)

char = Text.GetCharacter(code)


The computer uses numbers to represent the different characters (with the Text object). The letter A is 65, B is 66, C is 67, and so on until Z, which is 100.

Math.GetRandomNumber(26) gives you a random number between 1 and 26.

If you add 64 to this number, you'll get a random number between 65 and 100. When you pass this number to Text.GetCharacter(), you'll get the letter that represents the number.

You can then display the letter or do anything you want to it (maybe ask the user to guess it!).


Leave a comment if you have any questions!


Head to to download it and learn all about it!


Small and Basically yours,

   - Ninja Ed & Majed Marji

Comments (1)

  1. Computers Today (part 1 of 6)…/computers-today.aspx


    CS SPOTLIGHT: Girls in computer programming… why it matters!!!…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

    Computational Thinking – Videos & Papers by Jeannette Wing…/computational-thinking-videos-amp-papers-by-jeannette-wing.aspx

Skip to main content