Functions and SubRoutines
I am taking a programming class and am having some trouble grasping some of this stuff. I am new to programming and was hoping maybe someone could maybe explain this to me in "plain english"? Any help would be most appreciated.........The following is the assignment I am having some trouble with.
Fun with Functions and Subroutines
· Create a subroutine (not a function) called SquareIt that will take a decimal number and square it. Use module-level vars for the decimal number and the result. Do not use parameters. In a button click event, call SquareIt. After it returns, display a message box that displays something like, "The square of 5 is 25".
· Create a subroutine similar to as above, except use 2 parameters instead of module-level variables. The first parameter will be the decimal number to square. The second parameter will be a ByRef parameter that can be used to hold the squared decimal. Once again, display a message box as above.
· Do the same as above, but make it a function called Square. Square takes one parameter (the decimal number to square), and returns the squared decimal number in its return value. Once again, display a message box as above.
· Create a subroutine called ValidateRange that checks to see if an integer is within a specified range of numbers. Use parameters. The first parameter will be the integer to check. The second parameter will be the minimum number that is acceptable. The third parameter will be the maximum number that is acceptable. The fourth parameter is a boolean called bValid that holds whether the number is in range. In a button click event, call ValidateRange. After it returns, display a message box that displays something like, "The number 63 is not in range". Or, the number 7 is in range.
· Create a function called ValidRange that does the same thing except that it take just one parameter (the number to check) and returns the boolean in its return value. Once again, display a message box as above.
· Create a function called MonthName that accepts one integer parameter from 1 to 12 representing a month in the year. For example, 1 corresponds to January. The function should return a String representing the name of the month.
· Enhance the MonthName function so that it validates that the incoming parameter is in the range of 1 to 12. If it's not, return an empty string:
Return ""