The TFE and variant variable experiment.
-
Visual Basic and Visual Basic for Applications allow variables to be
declared as a specific type,
- or to be a general purpose type called Variant,
if you do not explicitly declare them to be a specific type.
- Variant variables take more bytes of memory and are slower than
the variable of the specific type.
- This experiment will show that their is a cost to not declaring
variables - the program will use more memory and will run slower.
- TFE stands for Time For Execution. The TFE will be greater when
the variable is not declared As Single or As Long or As Integer.
-
Use the Alt+PrintScreen technique to capture EACH of the message box
TFE results on the Windows Clipboard.
Paste the 5 different message boxes into some
application, such as Microsoft Word or even on an Excel spreadsheet.
Turn in this printout of the results of your experiment.
-
Due date: Before Thanksgiving break.
- Turn in the printout of your VBA code and a table showing
the 5
different times for execution (TFE). Note that TFEs will vary depending
on what computer you run the program. Older computers with slower memory
and/or slower CPUs will obviously have different times for execution than
newer computers. With the table of 5 times, discuss why the times vary so
much by utilizing lecture notes from Thursday, September 23rd and your
understanding of the Dim statement and Variant variables.
- Write a VBA function that will take a complete UNI student email
address, such as , and extract only the UNI ID portion
of it. Test it on sample data. Turn in a printout of this VBA function.
Save the workbook, as this will be needed in the future.
- Write a VBA function to generate a password consisting of 4
randomly chosen characters from a spreadsheet cell. We will use this
function to generate passwords from the COBRA user ids. Test it out on
some sample data. The passwords may include both digits and letters, if
the input cell has UNI user IDs in it. Test your VBA function on some
sample data. Turn in printout of this function.