Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. Module Module1
  2. Sub menuTitle(ByVal title As String, ByVal halfLength As Integer, ByRef lengthOfBox As Integer)
  3. Dim i As Integer = 0
  4. i = title.Length
  5. Console.Write("|")
  6. For x = 1 To halfLength - 1
  7. Console.Write(" ")
  8. Next
  9. Console.Write(title) ' displays the menu title and checks how long it is and then '
  10. For x = 1 To lengthOfBox - halfLength - 2 ' |
  11. Console.Write(" ") ' |
  12. Next ' v
  13. Console.Write("|")
  14. Console.WriteLine("")
  15. Console.Write("|")
  16. For x = 1 To halfLength - 1
  17. Console.Write(" ")
  18. Next
  19. For c = 1 To i
  20. Console.Write("-") ' underlines it with minuses as it sees how long it is so it knows how many to write
  21. Next
  22. For x = 1 To lengthOfBox - halfLength - 2
  23. Console.Write(" ")
  24. Next
  25. Console.Write("|")
  26. End Sub
  27. Sub Main()
  28. Dim numberOfOptions As Integer
  29. Dim menuTitleInput As String
  30. Console.WriteLine("What is the menu title?")
  31. menuTitleInput = Console.ReadLine()
  32. Console.WriteLine("How many options are there?")
  33. numberOfOptions = Console.ReadLine()
  34. ' asks the user how many options there are and then creates an array with x amount of options'
  35. Dim options(numberOfOptions - 1) As String
  36. 'a for loop for the user to enter the options'
  37. For i = 0 To numberOfOptions - 1
  38. Console.WriteLine("What is option " & i + 1)
  39. options(i) = Console.ReadLine()
  40. Next
  41. Dim lengthOfBox As Integer
  42. Dim max As Integer = 0
  43. For x = 0 To numberOfOptions - 2
  44. If options(x).Length > max Then ' finds out how long the longest string is
  45. max = options(x).Length
  46. End If
  47. Next
  48. If menuTitleInput.Length > max Then
  49. max = menuTitleInput.Length
  50. End If
  51. lengthOfBox = max
  52. Console.Write("+") 'The code to the left '
  53. For x = 1 To lengthOfBox + 4 'creates the topborder'
  54. Console.Write("=") '''''''''''''''''''''''
  55. Next
  56. Console.Write("+")
  57. Dim halfLength As Integer = lengthOfBox / 4
  58. Console.WriteLine("")
  59. menuTitle(menuTitleInput, halfLength, lengthOfBox) 'goes to the sub called menu and runs it through
  60. For x = 0 To numberOfOptions - 1
  61. Console.WriteLine("")
  62. Console.Write("| " & x + 1 & ". " & options(x)) 'Prints out the options and the option numbers'
  63. For i = 1 To lengthOfBox - options(x).Length
  64. Console.Write(" ")
  65. Next
  66. Console.Write("|")
  67. Next
  68. Console.WriteLine("")
  69. Console.Write("+") 'The code to the left '
  70. For x = 1 To lengthOfBox + 4 'creates the bottom border'
  71. Console.Write("=") '''''''''''''''''''''''
  72. Next
  73. Console.Write("+")
  74. Console.WriteLine("")
  75. Dim optionSelected As Integer
  76. Console.WriteLine("Please select an option...")
  77. optionSelected = Console.ReadLine()
  78. Console.WriteLine("You have chosen this option: " & options(optionSelected - 1)) 'writes the option selected'
  79. Console.ReadLine()
  80. End Sub
  81.  
  82. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement