Hey, I would consider myself to be new to the forum, posting wise, however i have been hovering around helping a few people out via PM and reading through certain posts which interest me :)
I study visual basic 2008 in education and i happened to fall upon Floyd's Triangle (http://en.wikipedia.org/wiki/Floyd%27s_triangle) and thought it would be an achievement if i were to alter the code shown in the following link for it to have a more appealing UI, in terms of spacing between certain characters and displaying errors messages where appropriate - http://en.wikipedia.org/wiki/Visual_Basic_.NET (bottom of the page, roughly 7/8 down)
The reason im posting this up to so you can learn a few tips, if you are studying vb.net and i would like to share with the community a sample of code which i managed to change from wikipedia to work with vb.net 2008 rather than other variations.
You are able to freely download vb.net 2008 completely free from the microsoft web page (http://www.microsoft.com/express/Downloads/#2010-Visual-Basic) Visual Studio 2008 Express.
Please comment below on what you think its good/effective or what needs improving on, otherwise i hope you enjoyed my contribution. Screenshots are below and code is presented below to.
NOTE: I wouldn't consider this as 100% mine as the majority of the code i found on wikipedia.org so therefore I'd just like to point out that i only did slight alterations and added in a few (not many) notes for a programmer/pseudo code user to read and hopefully understand. To be completely honest with you, im not too sure on what everything does, but i hope this inspires some to learn and look into to hopefully make clearer to others :)
Module Program
Sub Main()
Dim rows As Integer
'Input validation.
Do Until Integer.TryParse(ReadLine("Enter a value for how many rows to be displayed: "), rows) AndAlso rows >= 1
If rows < 1 Then
Console.WriteLine("Warning: You cannot have less than 1 row")
End If
Console.WriteLine("Allowed range is 1 and {0}", Integer.MaxValue)
Console.ReadLine()
Loop
'Output of Floyd's Triangle
Dim current = 1
For row = 1 To rows
For column = 1 To row
Console.Write("{0, -2}", current & " ") 'set spacing for each displayed number
current += 1 'set increase for each integar
Next
Console.ReadLine()
Next
End Sub
Function ReadLine(Optional ByVal prompt As String = Nothing) As String
If prompt IsNot Nothing Then
Console.Write(prompt)
End If
Return Console.ReadLine()
End Function
End Module
I have attached a comparison screenshot of both original and editied codes so you can see the editied/added pieces of code/information. Again, its not alot in comparison to whats there, but it seemed to fix a few errors i had with the original code. No, i don't think this would come in useful to most people, but it's been said you should be able to code Floyd's Triangle with a language to understand the basic comprehension and understanding of it.
Thanks for taking an interest in this post,
Many thanks,
Become.