I have this homework assignment that confuses the hell out of me. And i need help. I'm so confused please help me
When you open the Excel file, you will only see two buttons, Start and Exit. Now, click on the Design Mode button, you will see the third button, Select. This is because the buttons have an additional property Visible, in addition to the Enabled property that you used in MP4. In this part, you will create a subprocedure that sets the Enabled and Visible properties of the three buttons, Start, Select, and Exit. You can see that in the file given to you, the Start button is enabled and visible, Select button is disabled and invisible, and Exit button is disabled and visible.
The voting process is started when the user clicks on the Start button. When voting starts, Start button should get disabled, Select button should get enabled and visible, and Exit button should get enabled. When the voting process ends, the user clicks on the Exit button and then the exact opposite should happen: Start button should get enabled, Select button should get disabled and invisible, and Exit button should get disabled (Like the way it is initially in the file given to you).
Here is a summary of the desired functionality:
* Start voting
o Start button disabled
o Select button visible
o Select button enabled
o Exit button enabled
blnStart = True
* Stop voting
o Start button enabled
o Select button invisible
o Select button disabled
o Exit button disable
blnStart = False
Notice how Start voting and Stop voting change the same set of properties but in complete opposite value. Since, we want to either do a set of actions or just the opposite set of actions, we do not need to write two subprocedures. We can write one sub-procedure which takes a Boolean input and does one set of actions when the input is True and does the opposite set of actions when the input is False. In other words, the buttons can be enabled/disabled or made visible/invisible depending on the value of this boolean variable.
Do the following in your VBA Editor:
1. Declare a subprocedure called ToggleButtons that takes in one Boolean input, blnStart.
2. Write 4 lines of code that uses the subprocedure's input to assign the 4 properties: cmdStart.Enabled, cmdSelect.Visible, cmdSelect.Enabled, and cmdExit.Enabled. The input will be True if the user is starting the voting process and False if the user is ending the voting process. Remember that the Enabled and Visible properties are also Boolean values, so you can assign them blnStart or Not blnStart.
3. Update the subprocedures cmdStart_Click and cmdExit_Click to call the subprocedure ToggleButtons that you just created and pass in an appropriate value for the input.
Test: If things are working correctly, you should be able to click on the Start button to have the buttons change to the desired status. The Exit button should then be enabled for you to click, and you will be back to the original state. If your buttons disappear while testing the code that you wrote, you can go into Design mode and change the enabled and visible properties through the Properties window. However, finally you should have them as desired by the MP.
Bookmarks