La forma mas sencilla seria
Código:
Private Sub Text2_KeyPress(KeyAscii As Integer) 'Seria el text de contraseña
If KeyAscii = 13 Then
If Text1.Text = "Administrador" And Text2.Text = "TPHMM23VQK" Then
Form2.Show
Unload Me
Else
MsgBox "DATOS INCORRECTOS"
End If
End If
End Sub
Otra forma de hacerlo es utilizando una funcion:
Código:
Private Function autentificar(user As String, pass As String)
If user = "Administrador" And pass = "TPHMM23VQK" Then
Form2.Show
Unload Me
Else
MsgBox "DATOS INCORRECTOS"
End If
End Function
Private Sub Text2_Keypress(KeyAscii As Integer)
If KeyAscii = 13 Then a = autentificar(Text1.Text, Text2.Text)
End Sub