Access Programming Pocket Primer (The Pocket Primer Series) by Julitta Korol
Author:Julitta Korol [Korol, Julitta]
Language: eng
Format: epub
ISBN: 9781942270027
Publisher: Mercury Learning and Information
Published: 2015-05-10T21:00:00+00:00
Hands-On 5.4. Using the If…Then…Else Statement
1. Insert a new module and enter the following WhatTypeOf Day procedure in the module’s Code window:
Sub WhatTypeOfDay() Dim response As String Dim question As String Dim strMsg1 As String, strMsg2 As String Dim myDate As Date question = "Enter any date in the format mm/dd/yyyy:" _ & Chr(13) & " (e.g., 07/06/2011)" strMsg1 = "weekday" strMsg2 = "weekend" response = InputBox(question) myDate = Weekday(CDate(response)) If myDate >= 2 And myDate <= 6 Then MsgBox strMsg1 Else MsgBox strMsg2 End If End Sub
2. Run the WhatTypeOfDay procedure.
This procedure asks the user to enter any date. The user-supplied string is then converted to the Date data type with the built-in CDate function. Finally, the Weekday function converts the date into an integer that indicates the day of the week (see Table 5.3). The integer is stored in the variable myDate. The conditional test is performed to check whether the value of the variable myDate is greater than or equal to 2 (>=2) and less than or equal to 6 (<=6). If the result of the test is true, the user is told that the supplied date is a weekday; otherwise, the program announces that it’s a weekend.
3. Run the procedure a few more times, each time supplying a different date. Check the Visual Basic answers against your desktop or wall calendar.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8298)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6730)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6709)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6581)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6366)
Driving Data Quality with Data Contracts by Andrew Jones(6315)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6080)
Learning SQL by Alan Beaulieu(5994)
Weapons of Math Destruction by Cathy O'Neil(5779)
Big Data Analysis with Python by Ivan Marin(5361)
Data Engineering with dbt by Roberto Zagni(4356)
Solidity Programming Essentials by Ritesh Modi(4005)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3863)
Pandas Cookbook by Theodore Petrou(3574)
Blockchain Basics by Daniel Drescher(3292)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2905)
Feature Store for Machine Learning by Jayanth Kumar M J(2813)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2796)
Mastering Python for Finance by Unknown(2744)
