Applying It

Try to complete the following exercises by yourself.

Independent Exercise 1

Change exercise 1 from Chapter 9, “Control Statements,” to calculate the factorial using a function that calls itself—a recursive function. Hint: Define a function called Factorial with one argument n, and have it compute the factorial of the argument by calling itself. You will need to specify a condition to end the recursion.

Independent Exercise 2

Create and test a function that “pads” a String s with spaces up to a specified length n. If the length of the string passed in exceeds n, trim it to be at most n characters. The function should have an optional ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.