Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Sub menuTitle(ByVal title As String, ByVal halfLength As Integer, ByRef lengthOfBox As Integer)
- Dim i As Integer = 0
- i = title.Length
- Console.Write("|")
- For x = 1 To halfLength - 1
- Console.Write(" ")
- Next
- Console.Write(title) ' displays the menu title and checks how long it is and then '
- For x = 1 To lengthOfBox - halfLength - 2 ' |
- Console.Write(" ") ' |
- Next ' v
- Console.Write("|")
- Console.WriteLine("")
- Console.Write("|")
- For x = 1 To halfLength - 1
- Console.Write(" ")
- Next
- For c = 1 To i
- Console.Write("-") ' underlines it with minuses as it sees how long it is so it knows how many to write
- Next
- For x = 1 To lengthOfBox - halfLength - 2
- Console.Write(" ")
- Next
- Console.Write("|")
- End Sub
- Sub Main()
- Dim numberOfOptions As Integer
- Dim menuTitleInput As String
- Console.WriteLine("What is the menu title?")
- menuTitleInput = Console.ReadLine()
- Console.WriteLine("How many options are there?")
- numberOfOptions = Console.ReadLine()
- ' asks the user how many options there are and then creates an array with x amount of options'
- Dim options(numberOfOptions - 1) As String
- 'a for loop for the user to enter the options'
- For i = 0 To numberOfOptions - 1
- Console.WriteLine("What is option " & i + 1)
- options(i) = Console.ReadLine()
- Next
- Dim lengthOfBox As Integer
- Dim max As Integer = 0
- For x = 0 To numberOfOptions - 2
- If options(x).Length > max Then ' finds out how long the longest string is
- max = options(x).Length
- End If
- Next
- If menuTitleInput.Length > max Then
- max = menuTitleInput.Length
- End If
- lengthOfBox = max
- Console.Write("+") 'The code to the left '
- For x = 1 To lengthOfBox + 4 'creates the topborder'
- Console.Write("=") '''''''''''''''''''''''
- Next
- Console.Write("+")
- Dim halfLength As Integer = lengthOfBox / 4
- Console.WriteLine("")
- menuTitle(menuTitleInput, halfLength, lengthOfBox) 'goes to the sub called menu and runs it through
- For x = 0 To numberOfOptions - 1
- Console.WriteLine("")
- Console.Write("| " & x + 1 & ". " & options(x)) 'Prints out the options and the option numbers'
- For i = 1 To lengthOfBox - options(x).Length
- Console.Write(" ")
- Next
- Console.Write("|")
- Next
- Console.WriteLine("")
- Console.Write("+") 'The code to the left '
- For x = 1 To lengthOfBox + 4 'creates the bottom border'
- Console.Write("=") '''''''''''''''''''''''
- Next
- Console.Write("+")
- Console.WriteLine("")
- Dim optionSelected As Integer
- Console.WriteLine("Please select an option...")
- optionSelected = Console.ReadLine()
- Console.WriteLine("You have chosen this option: " & options(optionSelected - 1)) 'writes the option selected'
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement