i create one function but in return function so there is error like argument not specified for parameter 'arguments' of public function give some proper soluation and code for checking same value in database and if value are same then msg box show value are exists and new value then insert data

 Public Function UserExit(ByVal empcode As Boolean) As Boolean
        Dim cmd As New SqlCommand("select * from EmMaster where  EmploHba_EmpCode =@ec  ")

        cmd.Parameters.AddWithValue("@ec", txtEmpCode.Text.Trim())

        cmd.CommandType = CommandType.Text
        cmd.Connection = cn
        cn.Open()
        Dim dr As New SqlDataReader
        dr = cmd.ExecuteReader()
        If (dr.HasRows) Then
            Return True
        Else
            Return False
            cn.Close()

        End If
    End Function

      Private Sub txtEmpCode_LostFocus(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles txtEmpCode.LostFocus
        UserExit()
        UserExit.this.userexit()



        If(UserExit == False) then

        Else
            MessageBox.Show("EXIXTS DATA")
        End If

Your signatures for the userExit method don't match. You're calling it with no parameters but the method signature expects a variable called empCode.

hericles is correct.
Firstly you called the function without parameter value.
Secondly codes in function UserExit() need some change. No need to use datareader. Just you have to sure any value exist or not in the table.
I just change in your codes, you can use it if you want. Hope it can help you.

Public Function UserExit(empcode As String) As Boolean
    Dim conn As New MySql.Data.MySqlClient.MySqlConnection
    conn.ConnectionString = appConnectionString
    If conn.State = System.Data.ConnectionState.Closed Then conn.Open()
    Dim cmd As New MySql.Data.MySqlClient.MySqlCommand
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "Select Count(*) From EmMaster Where EmploHba_EmpCode =@empcd"
    cmd.Parameters.AddWithValue("@empcd", empcode)
    cmd.Connection = conn
    Dim Result As Integer = cmd.ExecuteScalar()
    cmd.Parameters.Clear()
    cmd.Dispose()
    conn.Close()
    conn.Dispose()
    If Result > 0 Then
        Return True
    Else
        Return False
    End If
End Function

Private Sub txtEmpCode_LostFocus(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles txtEmpCode.LostFocus
    If UserExit(CType(e.OriginalSource, TextBox).Text) Then
        MessageBox.Show("User Exists. Please input a unique value.")
        CType(e.OriginalSource, TextBox).SelectionStart = 0
        CType(e.OriginalSource, TextBox).SelectionLength = CType(e.OriginalSource, TextBox).Text.Length
    End If
End Sub
commented: ty for help me but +0
   If UserExit(CType(e.OriginalSource, TextBox).Text) Then

but one error show me this line like Unable to cast object of type 'System.Windows.Controls.Button' to type 'System.Windows.Controls.TextBox'.

You can write it as

If UserExit(txtEmpCode.Text) Then

Thanks Jim for editing my post. I posted that from smartphone. Thraer are no formating option exist.
Thanks Jim.

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.