real language

Bookmarking Digg Diigo DZone Earthlink Google
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Visual Basic (.NET)

Score: (2.27 in 102 votes)


Download Source | Write Comment

Alternative Versions


>>  Homer Simpson said on 12/20/05 22:12:50


>>  piggest said on 07/01/07 17:55:36

piggest You have forgotten at different points ...& VbCrLf... to make a Newline or more. Or insert somme Console.Writeline(...), can be too Console.Writeline("";). Looks omo better.
Greatings formm piggest

>>  Skip said on 11/13/07 15:06:40

Skip The last two lines of the song have not been catered for:

"No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall."

>>  J. Nobel aka JnXgates said on 04/23/08 05:25:20

J. Nobel aka JnXgates VB.Net sucks, I miss good 'ol VB. They should have updated VB, for the vintage VB'ers.
This code is especially boring, but leave it up to Microsoft, to force their ideology on 'ya. Like that screewwwwweeeddd up Vista, that ought to be a crime. It should be free, OS & lang(s)., when it first comes out. Anyway, The VB code is longer and more interesting

>>  Ben said on 11/22/08 00:40:32

Ben '' This will take into account the missing last two lines... and then loop back
'' as many times as you set it to repeat...

Module Bottles

Sub Main()

'Set up starting number of bottles and how many
'times we wish to repeat the song...
Dim StartCount = 99
Dim Repeat = 1

'Compose phrases and set up inclusion conditions...
Dim More = " more"
Dim MoreCount = 10 'inclusion condition for More...
Dim None = "No"
Dim Plural = "s"
Dim RemoveLast = "it"
Dim RemoveNext = "one"

Dim phrase1 = "{0}{1} bottle{2} of beer"
Dim phrase2 = String.Format("{0} on the wall", phrase1)
Dim phrase3 = "Take {0} down and pass it around"
Dim phrase4 = "Go to the store and buy some more"

Dim line1 = String.Format("{0},{1}{2},", phrase2, ControlChars.CrLf, phrase1)
Dim line2 = String.Format("{0},{1}{2}.", "{3}", ControlChars.CrLf, phrase2)

'Generate the lyrics...
Dim Count = StartCount
Dim RepeatCount = 0
While Count >= 0

'Write the first line...
Console.WriteLine(line1, _
IIf(Count > 0, _
Count, _
None), _
IIf(Count > MoreCount, _
String.Empty, _
More), _
IIf(Count = 1, _
String.Empty, _

'Decrement the counter...
Count = IIf(Count > 0, Count - 1, StartCount)

'Write the second line...
Console.WriteLine(line2, _
IIf(Count > 0, _
Count, _
None), _
IIf(Count > MoreCount, _
String.Empty, _
More), _
IIf(Count = 1, _
String.Empty, _
Plural), _
IIf(Count = StartCount, _
phrase4, _
String.Format(phrase3, _
IIf(Count = 0, _
RemoveLast, _
'Leave a gap between the verses...

'If we got to 0 and reset, the increment the repeat counter
If Count = StartCount Then RepeatCount += 1
If RepeatCount = Repeat Then Exit While

End While


End Sub

End Module

>>  VB.NET said on 07/20/09 04:50:58

VB.NET For those idiots saying VB.NET is boring because it is shorter than VB or others, you can just suck off or build a time machine in an ancient programming language to go back to those days. VB.NET is designed to be short, not to interest the programmer, but make him/her more productive and save time! And in case you're wondering, yes it makes me money, as well as a lot of other people.

>>  miguel said on 05/21/10 08:31:35

miguel I quite agree with you.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!




Security Code: