Question

In: Computer Science

Create code In visual Basic, Windows forms that uses case statements to convert the day of...

Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?

Solutions

Expert Solution

Program:

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim day As String
day = InputBox("Enter a day of the week: ")

Select Case day.ToLower
Case "sunday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 1)
Case "monday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 2)
Case "tuesday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 3)
Case "wednesday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 4)
Case "thursday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 5)
Case "friday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 6)
Case "saturday"
MessageBox.Show("Converted " & day & " of the week into Integer: " & 7)
Case Else
MessageBox.Show("Incorrect Day!! " & vbNewLine & day & " is not a day!!")

End Select
End Sub
End Class

Outputs:


Related Solutions

Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might use to represent a character within the game. A character should include six stats as instance variables – strength, dexterity, constitution, intelligence, wisdom and charisma (all types are int). Your class should have a constructor that initializes these six instance variables. Provide Properties with an appropriate set and get block for each instance variable. In addition, provide a method named getStatsTotal that calculates the...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
Code, pls. Thank you. Exercise - MPG Calculator Create a Windows Forms application and call it...
Code, pls. Thank you. Exercise - MPG Calculator Create a Windows Forms application and call it MPGCalculator Build a form that looks like the form in the video provided. The form consists of 4 labels, 2 textboxes and 3 buttons Name all controls properly. Certain labels do not have to be named Pay attention to video and set all design time properties accordingly. The "x" should be a hot key for the exit button When Calculate is clicked, you should...
I am trying to write code for a program in Visual Studo using Visual Basic programming...
I am trying to write code for a program in Visual Studo using Visual Basic programming language that computes the factorial of an entered number by using a For Loop. My problem is that it keeps re-setting the variable for Factorial. Below is my code if anyone can help. I want it to multiply the given number by that number - 1, then continuing to do so until it hits zero without multiplying by zero. Private Sub BtnCalculate_Click(sender As Object,...
Language: C++ NEEDS TO WORK IN VISUAL BASIC The code is broken and loops in a...
Language: C++ NEEDS TO WORK IN VISUAL BASIC The code is broken and loops in a few places please fix it #include<iostream> using namespace std; //function declaration void EnterRents(int*, int); void displayRents(int*, int); void selectionSort(int*, int); int sumRents(int* temp, int size) {    int sum = 0;    for (int i = 0; i < size; i++)    {        sum += *(temp + i);    }    return sum; } void Displaymemory(int* temp, int size) {    /*int...
Use Visual Basic Language In this assignment you will need to create a program that will...
Use Visual Basic Language In this assignment you will need to create a program that will have both a “for statement” and an “if statement”. Your program will read 2 numbers from the input screen and it will determine which is the larger of the 2 numbers. It will do this 10 times. It will also keep track of both the largest and smallest numbers throughout the entire 10 times through the loop. An example of the program would be...
In this project, you will create a Visual Basic solution to perform customer billing at the...
In this project, you will create a Visual Basic solution to perform customer billing at the Cyberian Internet Cafe. Please see below for the detailed instructions. You will create the project and then design a form using the image provided here. Then, add the necessary code to do the billing calculation and display the amount due. Instructions In this case, you will create a Visual Basic solution that performs customer billing for the Cyberian Internet Café. The Cyberian Internet Café...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
For each of the following Visual Basic code snippets, identify the syntax error.   If intX >...
For each of the following Visual Basic code snippets, identify the syntax error.   If intX > 100   lblResult.Text = "Invalid Data" End If   Dim str As String = "Hello" Dim intLength As Integer intLength = Length(str) If intZ < 10 Then   lblResult.Text = "Invalid Data"   Dim str As String = "123" If str.IsNumeric Then   lblResult.Text = "It is a number." End If   Select Case intX   Case < 0     lblResult.Text = "Value too low."   Case > 100     lblResult.Text = "Value too high."   Case Else     lblResult.Text = "Value...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT