below is a code which new password entered and compare with the confirmed password. At run time, it doesn't show error but when input password diferent that of the confirmation, it doesn't give any matching error.
please below why the system allow me to move to the next.

Private Sub txtpwdconf_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpwdconf.LostFocus
        Dim pwdconf, password As String
        Me.txtPassword.Text = Me.txtpwdconf.Text
        If txtpwdconf.Text <> txtPassword.Text Then
            Dim mySqlDBConnection As New SqlConnection(ConnectionString)
            Dim theSqlCommand As New SqlCommand(put, mySqlDBConnection)
            Dim theUsernameParam As New SqlParameter("@password", Me.txtPassword.Text)
            Dim thePasswordParam As New SqlParameter("@Pwdconf", Me.txtpwdconf.Text)
            Dim theReader As SqlDataReader = theSqlCommand.ExecuteReader(CommandBehavior.CloseConnection)

            If theReader.HasRows Then 'we have data, user exists
                MessageBox.Show("Password not Matching, Try again")
                Me.txtuser_id.Clear()
                Me.txtpwdconf.Clear()
                txtuser_id.Focus()
            End If
        End If
    End Sub

thanks
Gyamfi

I'm sorry if I am misunderstanding but it looks like you have set txtPassword to equal txtpwdconf and then you are comparing them:

Me.txtPassword.Text = Me.txtpwdconf.Text
If txtpwdconf.Text <> txtPassword.Text Then

In this case txtPassword would always equal txtpwdconf!

Your question is not so clear to me anyway as I understand your problem, basically you want to compare the value of text box and name of your text box are

1. txtPassword 
2.txtpwdconf

if I am right till now then
then look at your coding at line number 3 what it does

Me.txtPassword.Text = Me.txtpwdconf.Text

after execution of this line of code, it will assign the value of text box txtpwdconf to txtPassword
change this line

if   Me.txtPassword.Text = Me.txtpwdconf.Text then
'your line of code when condition is true
else
'your line of code when codition is not true
end if

If your problem is other then my understanding then feel free to explain

thanks,
I tried the last code, but it still not working. eg I entered password as 1234 and 12e4 as confirmed password for a newuser. Instead of getting the message password do not match, the cursor moved the next field. which means the copmarision is not working.
below is the code again. from your reply, u had understood my question
Private Sub txtpwdconf_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpwdconf.LostFocus
Dim pwdconf, password As String
Me.txtPassword.Text = Me.txtpwdconf.Text
If Me.txtPassword.Text = Me.txtpwdconf.Text Then
Dim mySqlDBConnection As New SqlConnection(ConnectionString)
Dim theSqlCommand As New SqlCommand(put, mySqlDBConnection)
Dim theUsernameParam As New SqlParameter("@password", Me.txtPassword.Text)
Dim thePasswordParam As New SqlParameter("@Pwdconf", Me.txtpwdconf.Text)
' Dim theReader As SqlDataReader = theSqlCommand.ExecuteReader(CommandBehavior.CloseConnection)
Else

MessageBox.Show("Password not Matching, Try again")
Me.txtuser_id.Clear()
Me.txtpwdconf.Clear()
txtuser_id.Focus()
End If

End Sub

First always use code tag to post your code ok still you repeat the same mistake......
try this

Private Sub txtpwdconf_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpwdconf.LostFocus
Dim pwdconf, password As String
'Me.txtPassword.Text = Me.txtpwdconf.Text its your mistake ok try to understand the 
'the meaning of this line 
If Me.txtPassword.Text = Me.txtpwdconf.Text Then
Dim mySqlDBConnection As New SqlConnection(ConnectionString)
Dim theSqlCommand As New SqlCommand(put, mySqlDBConnection)
Dim theUsernameParam As New SqlParameter("@password", Me.txtPassword.Text)
Dim thePasswordParam As New SqlParameter("@Pwdconf", Me.txtpwdconf.Text)
' Dim theReader As SqlDataReader = theSqlCommand.ExecuteReader(CommandBehavior.CloseConnection)
Else

MessageBox.Show("Password not Matching, Try again")
Me.txtuser_id.Clear()
Me.txtpwdconf.Clear()
txtuser_id.Focus()
End If

End Sub

I just change your mistake to comment, hope it will help you

it works perfectly.
thanks

can any one tell me same code but using access database

@Nee_1 you need to start a new thread based on your question, this is already answered. Also before starting that thread search within Daniweb to see already available solutions to your question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.