Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. Dim nombre, telefono, email, fechaNacStr, respuesta, masJovenNombre, telefonoMasJoven, emailMasJoven As String
  2. Dim fechaNac, fechaNacMasJoven As Date
  3. Dim contador As Integer = 0
  4. Dim activarBucle As Boolean = False
  5. Do
  6. contador = contador + 1
  7. Do
  8. Console.Write("Nombre Persona {0}: ", contador)
  9. nombre = Console.ReadLine
  10. Loop While String.IsNullOrWhiteSpace(nombre)
  11.  
  12. Do
  13. Console.Write("Teléfono: ")
  14. telefono = Console.ReadLine
  15. Loop Until telefono.Length >= 9 AndAlso telefono.StartsWith("6") OrElse telefono.StartsWith("7") OrElse telefono.StartsWith(9)
  16.  
  17.  
  18.  
  19. Do
  20.  
  21. Console.Write("Email: ")
  22. email = Console.ReadLine()
  23. If Not ((email.Contains("@") AndAlso email.Contains(".") AndAlso email.IndexOf("@") < email.IndexOf(".") AndAlso email.LastIndexOf("@") = email.IndexOf("@")) OrElse String.IsNullOrWhiteSpace(email)) Then
  24.  
  25. Console.WriteLine(vbTab & "El email introducido no es válido")
  26. End If
  27. Loop Until (email.Contains("@") AndAlso email.Contains(".") AndAlso email.IndexOf("@") < email.IndexOf(".") AndAlso email.LastIndexOf("@") = email.IndexOf("@")) OrElse String.IsNullOrWhiteSpace(email)
  28.  
  29. 'Do
  30. ' Console.Write("Email: ")
  31. ' email = Console.ReadLine
  32.  
  33. ' If Not String.IsNullOrWhiteSpace(email) AndAlso email.Contains("@") Then
  34. ' Dim emailCortado As String = email.Substring(email.IndexOf("@"))
  35. ' Else
  36. ' activarBucle = True
  37. ' End If
  38. 'Loop While Not String.IsNullOrWhiteSpace(email) OrElse emailCortado.Contains(email.IndexOf("@"))
  39.  
  40. Do
  41. Console.Write("Introduce la fecha de nacimiento: ")
  42. fechaNacStr = Console.ReadLine
  43. Loop Until Date.TryParse(fechaNacStr, fechaNac) AndAlso fechaNac < Today
  44. If contador = 1 Then
  45. masJovenNombre = nombre
  46. telefonoMasJoven = telefono
  47. emailMasJoven = email
  48. fechaNacMasJoven = fechaNac
  49. Else
  50. If fechaNac >= fechaNacMasJoven Then
  51. masJovenNombre = nombre
  52. telefonoMasJoven = telefono
  53. emailMasJoven = email
  54. fechaNacMasJoven = fechaNac
  55. End If
  56. End If
  57. Do
  58. Console.Write("Otra Persona(S/N): ")
  59. respuesta = Console.ReadLine
  60. Loop Until respuesta.ToLower = "s" OrElse respuesta.ToLower = "n"
  61.  
  62.  
  63.  
  64. Loop While respuesta.ToLower = "s"
  65. Console.WriteLine()
  66. 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)
  67. Console.ReadKey()
  68. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement