If txt2 = txtUserName.Text And txt2 = txtPassword.Text Then
改为
If RTrim(txt1) = txtUserName.Text And RTrim(txt2) = txtPassword.Text Then