Week of
PasswordChar
, which
is a character that can be used to block out the password field so
it can't be read. A typical password character is the asterisk (*)
but you can choose another if you like.
The image shown below has had a few other changes made to it, but you can create your form however you want.
Save the spreadsheet file as a Macro Enabled Workbook (.xlsm
)
file before you write more code. Name your spreadsheet with your
network login followed by _l07.xlsm
. For example, if
your network login was barn4520
, then your lab file
should be named barn4520_l07.xlsm
. Save often.
All tasks are to be completed on your own.
Show the Developer Tab in Excel. Click File / Options Customize Ribbon and check the option for Developer Tab.
Put all code into a Module. Use a different Module for each task and name them appropriately as Task1 or Task2 etc.
Copy and paste this header into your code modules and fill it out:
Option Explicit ' ==== CP212 Windows Application Programming ===============+ ' Name: Your Name ' Student ID: ' Date: ' Program title: ' Description: '===========================================================+
Make sure you test your tasks before submitting it to the Dropbox be marked.
When finished upload your file to the Lab 7 Task Dropbox in MyLearingSpace.
When the user tries to close the form by clicking the upper right X, the following sub can be used
Private Sub UserForm_QueryClose(cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then cmdCancel_Click End Sub
Create the userform shown below:
This form contains a frame, labels, a RefEdit
control,
two buttons, and a scrollbar. When you click the Sum button,
it should display a message box indicating the Sum of the selected
cells.
Note: The RefEdit
control has a Value
property which returns a string containing the address of the
selected range. To create a range object from this address use a
line like:
Dim range1 As Range set range1 = Range(refEdit.Value)
When you click the Cancel button, the form should
close/unload. Use the Accelerator
property for each
button to include the HotKey (displays the underscore and
allows that key to execute the button when pressing Alt.)
To activate the scrollbar, you need to access and modify its properties such as ScrollTop and ScrollHeight. Please note that scrollbar can be activated by assigning appropriate value to the ScrollBars property of the form.
Note