Friday, September 08, 2006

Fun with VBA functions!

So far we've only been using the built in VBA functions (such as MsgBox, CInt or IsNumeric) as we've needed them. Today we're going to have some fun finding out what else is out there! Check out the list of VB functions at Microsoft's Visual Basic Scripting Functions (right-click and open in a new window).

How many of the functions do you recognise? We'll see how many we can count in class!

Open a new Excel Spreadsheet and save it as "vba_functions.xls". See if you can use this reference to achieve the following:
  1. Create a new Sub call Capitals that asks the user to input some text (using an Input box) and store it in a variable. Your sub should then use a MsgBox to repeat the text back to the User. When you've got that working, modify your function so that when your MsgBox pops up, the text is all in upper-case (capital letters).
  2. Create a new Sub call Reversi that will ask the user to enter in some text, and will respond with the text completely reversed! For e.g., if the user types in: Hi there!, your Sub will then display: !ereht iH, in a MsgBox.

0 Comments:

Post a Comment

<< Home