C# Visual Studios
Create a GUI application that prompts users to enter a ten (10) digit phone number, with hyphens and parentheses included – this input should be validated as a phone number adhering to the (XXX)-XXX-XXXX format.
Should the user input an incorrect format, an error message should print to screen and your phone number textbox should be highlighted in red.
Should an appropriately formatted phone number be entered, an acceptance message should printed to screen and your phone number textbox should be highlighted in green.
C# Code:
File: Form1.Designer.cs
namespace PhoneNumber
{
partial class Form1
{
///
<summary>
/// Required designer
variable.
///
</summary>
private
System.ComponentModel.IContainer components = null;
///
<summary>
/// Clean up any
resources being used.
///
</summary>
/// <param
name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void
Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
<summary>
/// Required method for
Designer support - do not modify
/// the contents of this
method with the code editor.
///
</summary>
private void
InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.tbPhoneNumber = new System.Windows.Forms.TextBox();
this.btnValidate = new System.Windows.Forms.Button();
this.lblMsg = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(23, 79);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(163, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Please enter your phone number:";
//
// tbPhoneNumber
//
this.tbPhoneNumber.Location = new System.Drawing.Point(192,
76);
this.tbPhoneNumber.Name = "tbPhoneNumber";
this.tbPhoneNumber.Size = new System.Drawing.Size(140, 20);
this.tbPhoneNumber.TabIndex = 1;
//
// btnValidate
//
this.btnValidate.Location = new System.Drawing.Point(138,
120);
this.btnValidate.Name = "btnValidate";
this.btnValidate.Size = new System.Drawing.Size(75, 23);
this.btnValidate.TabIndex = 2;
this.btnValidate.Text = "Validate";
this.btnValidate.UseVisualStyleBackColor = true;
this.btnValidate.Click += new
System.EventHandler(this.btnValidate_Click);
//
// lblMsg
//
this.lblMsg.AutoSize = true;
this.lblMsg.Font = new System.Drawing.Font("Monotype Corsiva",
15.75F, System.Drawing.FontStyle.Italic,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMsg.Location = new System.Drawing.Point(63, 162);
this.lblMsg.Name = "lblMsg";
this.lblMsg.Size = new System.Drawing.Size(0, 25);
this.lblMsg.TabIndex = 3;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(399, 248);
this.Controls.Add(this.lblMsg);
this.Controls.Add(this.btnValidate);
this.Controls.Add(this.tbPhoneNumber);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Phone Number Validater";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private
System.Windows.Forms.Label label1;
private
System.Windows.Forms.TextBox tbPhoneNumber;
private
System.Windows.Forms.Button btnValidate;
private
System.Windows.Forms.Label lblMsg;
}
}
File: Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PhoneNumber
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Method that
validates the textbox text
bool validate(String
phNumber)
{
//Checking for format
if (phNumber[0] == '(' && phNumber[4] == ')' &&
phNumber[5] == '-' && phNumber[9] == '-')
{
return false;
}
else
{
return true;
}
}
//Button click event
handler
private void
btnValidate_Click(object sender, EventArgs e)
{
//Fetching phone number from textbox
String phNum = tbPhoneNumber.Text;
//Empty text
if (phNum.Length == 0)
{
tbPhoneNumber.BackColor = Color.Red;
lblMsg.Text = "Invalid phone number";
}
//Not in correct format
else if (validate(phNum))
{
tbPhoneNumber.BackColor = Color.Red;
lblMsg.Text = "Invalid phone number";
}
else
{
tbPhoneNumber.BackColor = Color.Green;
lblMsg.Text = "Valid phone number";
}
}
}
}
__________________________________________________________________________________
Sample Run:
C# Visual Studios Create a GUI application that prompts users to enter a ten (10) digit...
Travel Expenses Create a GUI in C# Visual Studios application 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 taxi charges, if any...
c++ please :) First, ask the user to enter a year (4-digit) and what week day does this year starts with (String) For example, the year 2018 starts with the week day "Friday". In this case, the calendar should start from January 1 which is Friday, 2018 Your program should produce a formatted calendar for the specified year and there should be a blank line after each month. Moreover, the month and the year should be centered over each month....
I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...
write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...