Answer to Question #251604 in C# for Israel

Question #251604

Create a windows application that contains two TextBox objects and two Button objects. One of the TextBox objects and one of the buttons are initially invisible. The first textbox should be used to input a password. The textbox should be masked to some character of your choice so that the characters entered by the user are not seen on the screen. When the user clicks the first button, the second TextBox object and button object should be displayed with a prompt asking the user to reenter his or her password. Now the user clicks the second button, have the application compare the values entered to make sure they are the same. Display an appropriate message indicating whether they are the same.


1
Expert's answer
2021-10-15T01:28:47-0400
namespace PasswordProject
{
    partial class frmPasswordProject
    {
        /// <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.btnCheck = new System.Windows.Forms.Button();
            this.btnDisplay = new System.Windows.Forms.Button();
            this.lblYourPassword = new System.Windows.Forms.Label();
            this.txtSecretPassword = new System.Windows.Forms.TextBox();
            this.txtYourPassword = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(56, 31);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(89, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Secret password:";
            // 
            // btnCheck
            // 
            this.btnCheck.Location = new System.Drawing.Point(102, 101);
            this.btnCheck.Name = "btnCheck";
            this.btnCheck.Size = new System.Drawing.Size(75, 23);
            this.btnCheck.TabIndex = 4;
            this.btnCheck.Text = "Check";
            this.btnCheck.UseVisualStyleBackColor = true;
            this.btnCheck.Visible = false;
            this.btnCheck.Click += new System.EventHandler(this.btnCheck_Click);
            // 
            // btnDisplay
            // 
            this.btnDisplay.Location = new System.Drawing.Point(186, 101);
            this.btnDisplay.Name = "btnDisplay";
            this.btnDisplay.Size = new System.Drawing.Size(75, 23);
            this.btnDisplay.TabIndex = 3;
            this.btnDisplay.Text = "Display";
            this.btnDisplay.UseVisualStyleBackColor = true;
            this.btnDisplay.Click += new System.EventHandler(this.btnDisplay_Click);
            // 
            // lblYourPassword
            // 
            this.lblYourPassword.AutoSize = true;
            this.lblYourPassword.Location = new System.Drawing.Point(56, 66);
            this.lblYourPassword.Name = "lblYourPassword";
            this.lblYourPassword.Size = new System.Drawing.Size(80, 13);
            this.lblYourPassword.TabIndex = 3;
            this.lblYourPassword.Text = "Your password:";
            this.lblYourPassword.Visible = false;
            // 
            // txtSecretPassword
            // 
            this.txtSecretPassword.Location = new System.Drawing.Point(161, 31);
            this.txtSecretPassword.Name = "txtSecretPassword";
            this.txtSecretPassword.PasswordChar = '*';
            this.txtSecretPassword.Size = new System.Drawing.Size(100, 20);
            this.txtSecretPassword.TabIndex = 1;
            this.txtSecretPassword.UseSystemPasswordChar = true;
            // 
            // txtYourPassword
            // 
            this.txtYourPassword.Location = new System.Drawing.Point(161, 63);
            this.txtYourPassword.Name = "txtYourPassword";
            this.txtYourPassword.Size = new System.Drawing.Size(100, 20);
            this.txtYourPassword.TabIndex = 2;
            this.txtYourPassword.Visible = false;
            // 
            // frmPasswordProject
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(298, 149);
            this.Controls.Add(this.txtYourPassword);
            this.Controls.Add(this.txtSecretPassword);
            this.Controls.Add(this.lblYourPassword);
            this.Controls.Add(this.btnDisplay);
            this.Controls.Add(this.btnCheck);
            this.Controls.Add(this.label1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "frmPasswordProject";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Password project";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button btnCheck;
        private System.Windows.Forms.Button btnDisplay;
        private System.Windows.Forms.Label lblYourPassword;
        private System.Windows.Forms.TextBox txtSecretPassword;
        private System.Windows.Forms.TextBox txtYourPassword;
    }
}





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 PasswordProject
{
    public partial class frmPasswordProject : Form
    {
        public frmPasswordProject()
        {
            InitializeComponent();
        }
        /// <summary>
        /// When the user clicks the first button, the second TextBox object and button object should be 
        /// displayed with a prompt asking the user to reenter his or her password.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDisplay_Click(object sender, EventArgs e)
        {
            lblYourPassword.Visible = true;
            txtYourPassword.Visible = true;
            btnCheck.Visible = true;
        }
        /// <summary>
        ///  Now the user clicks the second button, have the application compare the values
        ///  entered to make sure they are the same. Display an appropriate message indicating whether they are the same.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheck_Click(object sender, EventArgs e)
        {
            if (txtSecretPassword.Text == txtYourPassword.Text)
            {
                MessageBox.Show("The passwords are the same.");
            }
            else {
                MessageBox.Show("The passwords are NOT the same.");
            }
        }
    }
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS