Dim lines As String() = IO.File.ReadAllLines(FILE_NAME)

If System.IO.File.Exists(FILE_NAME) = True Then

    For i = 0 To lines.Count - 1

        Dim userkey As String = System.IO.File.ReadAllLines(FILE_NAME)(i)

        If key.Text.Contains(userkey) Then
            'shows many msgs at  once i want to show only one msg
            MsgBox("Thanks for registering ")
        Else

        End If

        If Not key.Text.Contains(userkey) Then
            MsgBox("Code error ")
        End If

    Next

End If

The first problem is that you are reading the entire file on every iteration of the loop. Read the entire file once before the loop, then iterate over the lines. Or you could read the file once and use a For Each as in

Dim found As Boolean = False

For Each userkey As String in System.IO.File.ReadAllLines(FILE_NAME)
    If key.Text.Contains(userkey) Then
        found = True
        Exit For
    End If
Next

If found Then
    MsgBox("Thanks for registering ")
Else
    MsgBox("Code error ")
End If

However, I think you should be using

If key.Text = userkey Then

instead so that you don't get a false match when key.Text = "sernam" and userkey = "username".