I have a windows form that has three text boxes one each for the current password, new password and confirm new password . The purpose of the form is to allow a user to change his/her password and to confirm the change . I am using a Data access object (DAO) for communicating with the passwords database. The block of code that has been commented out shows my attempts so far at implement this. Can anyone guide me as to how to implement this bit of functionality?
Below is the code for the "save" button in the "Change Password" form.

private void btnSave_Click(object sender, EventArgs e)
                //byte passConfirm = 0;
                //string resultMsg = "";
                // Display message if user attempts to save data with blank fields
                if (txtCurrentPassword.Text.Trim().Equals("") ||
                    txtNewPassword.Text.Trim().Equals("") ||
                    MessageBox.Show("Please enter your password.");
               // else if (txtCurrentPassword.Text.Trim() != aLogin.login(aPass));
               /* else // check if the user's input matches the current password
                    passConfirm = aUserLogin.login(txtCurrentPassword.Text,ref resultMsg);
                    if (passConfirm == 1)
                        // Success. Pasword matches
                        User aNewPassword = new User(txtCurrentPassword.Text,

                if (txtCurrentPassword.Text != txtNewPassword.Text ||
                    txtNewPassword.Text == txtConfirmPassword.Text)

                    MessageBox.Show("The passwords do not match.");
                    txtConfirmPassword.Text = "";
                    txtCurrentPassword.Text = "";
                    txtNewPassword.Text = "";
            }// end try
            catch (Exception ex)
        }// end btnSave_Click()method

I have used string.Compare or ComporeTo to compare strings. I think that equality function checks only that strings are really same instances.

string.IsNullOrEmpty(oldpassword.Text) is very useful

This article has been dead for over six months. Start a new discussion instead.