Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2015. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Tree
- '
- ' Author: Joseph L. Bolen
- ' Date Created: June 2015
- '
- ' Description: Simple console app making a tree.
- '
- ' Documentation is at:
- ' App's Visual Basic .NET code is at http://pastebin.com/u/jaybeeoh
- ' Video tutorials at YouTube: http://www.youtube.com/user/bolenpresents
- '-------------------------------------------------------------------------------------------
- Module Tree
- Dim limbs As Integer
- Sub Main()
- Console.Clear()
- Do
- Console.Write("How many limbs for your tree? Enter 1-15 or press Enter to end program: ")
- Dim text As String = Console.ReadLine()
- If text.Trim = String.Empty Then Exit Do
- If Integer.TryParse(text, limbs) Then
- If limbs > 0 AndAlso limbs < 16 Then
- MakeTree()
- Else
- Console.WriteLine("Please enter a number value between 1 and 15. Please reenter.")
- End If
- Else
- Console.WriteLine("Please enter a number value. Please reenter.")
- End If
- Loop
- End Sub
- Sub MakeTree()
- Dim ctr As Integer = 40
- Console.Clear()
- Console.WriteLine()
- Console.WriteLine(Space(ctr) & "I")
- For idx As Integer = 1 To limbs
- Console.WriteLine(Space(ctr - idx) & StrDup(idx, "*") & "I" & StrDup(idx, "*"))
- Next
- ' Adjust trunk size and height to be proportional to the number of limbs.
- Dim trunk As Integer = Convert.ToInt32(limbs * 0.2)
- Dim trunkHeight As Integer = trunk
- If trunkHeight < 1 Then
- Console.WriteLine(Space(ctr) & "I")
- Else
- For idx = 1 To trunk
- Console.WriteLine(Space(ctr - trunk) & StrDup(trunk, "*") & "I" & StrDup(trunk, "*"))
- Next
- End If
- Console.WriteLine()
- Console.WriteLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment