solve the question from programming with visual basic 2015,chapter 13.C exercice
ID: 3576412 • Letter: S
Question
solve the question from programming with visual basic 2015,chapter 13.C exercice No.8
In this exercise, you use a Microsoft Access database named Calories. The database, which is stored in the VB2015Chap13Access DatabasesCalories.accdb file, keeps track of the calories consumed during the day. The database contains one table named tblCalories. Each record has the following six fields: Day, Breakfast, Lunch, Dinner, Dessert, and Snack. The Day field is a text field; the other fields are numeric. The user should be able to display the total number of calories consumed in the entire dataset. He or she should also be able to display the total calories consumed for a specific meal, such as the total calories consumed for breakfasts, lunches, dinners, desserts, or snacks. In addition, the user should be able to display the total calories consumed on a specific day, the number of days in which more than 1,200 calories were consumed, and the average number of calories consumed per day. a. Create an application, using the following names for the solution and project, respectively: Calorie Counter Solution and Calorie Counter Project. Save the application in the VB2015Chap13 folder. b. Connect the application to the Calories database, and then drag the tblCalories object to the form. Make the appropriate modifications to the DataGridView control. The user should not be able to add, edit, delete, or save records. c. Code the application. Use the application to answer the following questions: How many calories were consumed in the entire dataset? How many calories were consumed for desserts? How many calories were consumed on 12/21/2017? On how many days were more than 1,200 calories consumed? What is the average number of calories consumed per day?
Explanation / Answer
1. Create a form with 6 buttons as Day, Breakfast, Lunch, Dinner, Dessert and Snacks respectively.
2. Also there would be two more buttons namely TotalCal and Average which calculates the total Calorie and the average calories
3. You can also add two more buttons for Clearing the text and Exiting the form as Clear and Exit namely.
2. Create a database as tblCalories which has the following Columns
Day, Breakfast, Lunch, Dinner, Dessert and Snacks, Total
3.Connect the application to calories database
Private Sub TotalCal_Click ( ByVal Sender as System.Object, ByVal e As System.EventArgs)
Handles TotalCal.Click
Public Class Calorie
Dim Total as Integer
Dim Day as Date
Dim Avg as Integer
Dim Breakfast,Lunch,Dinner,Dessert,Snacks as Integer
Total = Breakfast + Lunch + Dinner + Dessert + Snacks
TotalCal.Button = Total
sql = "UPDATE tblCalories SET Total = ' " & Total.Cal & " '
Avg = Total/5
Average.Text = Avg
Dim Day1 = select Day from tblCalories ;
Dim Dessert1 = Select Dessert from tblCalories where date = sysdate
Dim Day2 = Select Total from tblCalories where date=12/21/2017
Dim More = Select Date from tblCalories where Total >1200
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.