Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

your job is to use Select Case Blocks and Do/For Loops to design a clock and calendar interface. So that we are on the same

your job is to use Select Case Blocks and Do/For Loops to design a clock and calendar interface. So that we are on the same page, here are some parameters:

You need not make a representation of a clock. All you need to do is output the current time and date (such as 11:16 AM on Wednesday October 19, 2018). I am aware that there are functions that do this, but I do not want you to use them directly. Clocks and calendars are the perfect example to build these constructions.

1. Start your program by asking the user to input the current weekday (as a word), month (as a number), day, year, and time (in hours, minutes, seconds, and the AM/PM designation). Each of these individual elements should be entered in a separate spot.

2. Use a select case block to handle the original assignment of a day counter from the weekday entered. Sunday should be 0, Monday 1, etc. You will use this counter and a Mod function to determine for the future which weekday it is.

3. Determine if it is a leap year. If it is divisible by 4, then it is.

4. Write a select case block that manages how many days the current month has. Remember that for February, this is dependent upon whether or not it is a leap year.

5. Since a clock runs indefinitely, the entire process after the initial entry should be a Do Loop (which serves the purpose of the years). Make this Do Loop a subroutine so that the inputs must come first.

6. Since the mechanisms of a clock and a calendar are finitely driven (they have predictable ends), these should be managed by a nested For Loop. The order in which the nesting should occur should be year, month, day, hour, minute, second.

7. For reference, here are the bounds: -Months have variable numbers of days: January - 31, February - 28 (29 in leap year), March - 31, April - 30, May - 31, June - 30, July - 31, August - 31, September - 30, October - 31, November - 30, December - 31 -A day has 24 hours. AM and PM flips on the attainment of 12 (12 AM is midnight, 12 PM is noon) -An hour has 60 minutes -A minute has 60 seconds

Use the following to manage a second:

Start the clock by using a button. The button when you code it will contain all of the code. Normally a button will have an action that will start with Private Sub ...

Start the button instead with this: Private Async Sub ... (so in other words, type Async in between Private and Sub on your button)

Now, just to clarify (as I have had people get tripped up on this):

The whole process within the button (after the population of the current time) is a Do Loop. WITHIN that Do Loop, you will have a group of For Loops. I highly suggest working out the seconds, and then building the loop around it for minutes, and then for hours, etc.

To make your system wait one second, this is the best approach. I misled you, and for that I apologize:

Use the command Await Task.Delay(1000)

This makes it wait exactly one second before anything else occurs.

Hints:

Manage AM and PM as an IF statement within the loop (when the 12th hour is attained, flip it)

Write your For loop bounds regarding days with an initial value of 1 and a terminal value of numberOfDays. That way, the Select Case Block can help you to only have to handle this once. Do not forget to add one to the initial counter to help you with displaying the correct day of the week.

Your indexing variables will be used to help make decisions (such as how many days the month has, does AM/PM flip, and that the 13th hour of the day is 1 PM). This does not mean that they will be modified, but rather that they will be essential to decisions along the way.

This process will go on and on and on. To end it, just close the form window.

A good way to do this process is iteratively. Start with seconds. Make sure it works. Then build minutes around it. Then build hours around it.

Your for loops will start at the input time. As a consequence, you will need to manage what happens when the end is attained. In other words, you need to reset the subroutine's parameter variables because the index will need that on successive passes of the do loop. If you have questions about this, please let me know.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What is the relationship between humans and nature?

Answered: 1 week ago