Lab 4.3 - Pyramid

Pyramid-of-the-Sun by Joel Bedford,

The science of Mathematics is very old, almost older than recorded history. Ancient Egyptians used it to build gigantic, perfectly aligned pyramids out of massive stone blocks. It shouldn't be too difficult to build one of your own.

Write an application that will display a pyramid out of any single character the user gives, with as many rows as the user specifies (up to 12).

When the Draw button is clicked, your program should first check to make sure that the user has offered exactly one character, and has specified a number of rows as a numeric value between 1 and 12, inclusive. If not, the user should be given a MsgBox that explains his or her error, and then the program should return to the form without displaying a pyramid. Otherwise, the program should then display a pyramid, thus:


Note that the number of characters (in this case, an asterisk) starts at one and increases by one each row.

If the Inverted Check Box is checked, the pyramid should be drawn upside-down.

HINTS: You'll want to use a loop, actually two nested loops, to create the pyramid. Use the concatenation operator to add to your result string. Remember that your entire pyramid is going to be a single string. When you invert, don't forget to watch your Step (get it?). Use a monospace font (such as Courier).