Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim nombre, telefono, email, fechaNacStr, respuesta, masJovenNombre, telefonoMasJoven, emailMasJoven As String
- Dim fechaNac, fechaNacMasJoven As Date
- Dim contador As Integer = 0
- Dim activarBucle As Boolean = False
- Do
- contador = contador + 1
- Do
- Console.Write("Nombre Persona {0}: ", contador)
- nombre = Console.ReadLine
- Loop While String.IsNullOrWhiteSpace(nombre)
- Do
- Console.Write("Teléfono: ")
- telefono = Console.ReadLine
- Loop Until telefono.Length >= 9 AndAlso telefono.StartsWith("6") OrElse telefono.StartsWith("7") OrElse telefono.StartsWith(9)
- Do
- Console.Write("Email: ")
- email = Console.ReadLine()
- If Not ((email.Contains("@") AndAlso email.Contains(".") AndAlso email.IndexOf("@") < email.IndexOf(".") AndAlso email.LastIndexOf("@") = email.IndexOf("@")) OrElse String.IsNullOrWhiteSpace(email)) Then
- Console.WriteLine(vbTab & "El email introducido no es válido")
- End If
- Loop Until (email.Contains("@") AndAlso email.Contains(".") AndAlso email.IndexOf("@") < email.IndexOf(".") AndAlso email.LastIndexOf("@") = email.IndexOf("@")) OrElse String.IsNullOrWhiteSpace(email)
- 'Do
- ' Console.Write("Email: ")
- ' email = Console.ReadLine
- ' If Not String.IsNullOrWhiteSpace(email) AndAlso email.Contains("@") Then
- ' Dim emailCortado As String = email.Substring(email.IndexOf("@"))
- ' Else
- ' activarBucle = True
- ' End If
- 'Loop While Not String.IsNullOrWhiteSpace(email) OrElse emailCortado.Contains(email.IndexOf("@"))
- Do
- Console.Write("Introduce la fecha de nacimiento: ")
- fechaNacStr = Console.ReadLine
- Loop Until Date.TryParse(fechaNacStr, fechaNac) AndAlso fechaNac < Today
- If contador = 1 Then
- masJovenNombre = nombre
- telefonoMasJoven = telefono
- emailMasJoven = email
- fechaNacMasJoven = fechaNac
- Else
- If fechaNac >= fechaNacMasJoven Then
- masJovenNombre = nombre
- telefonoMasJoven = telefono
- emailMasJoven = email
- fechaNacMasJoven = fechaNac
- End If
- End If
- Do
- Console.Write("Otra Persona(S/N): ")
- respuesta = Console.ReadLine
- Loop Until respuesta.ToLower = "s" OrElse respuesta.ToLower = "n"
- Loop While respuesta.ToLower = "s"
- Console.WriteLine()
- Console.WriteLine("La persona más joven se llama {0} ,su teléfono es {1}, nació el {2} y su email es {3}", masJovenNombre, telefonoMasJoven, fechaNacMasJoven, emailMasJoven)
- Console.ReadKey()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement