Language Visual Basic (.NET)
Date: | 04/20/05 |
Author: | Anonymous |
URL: | n/a |
Comments: | 7 |
Info: | n/a |
Score: | ![]() |
Download Source | Write Comment
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!
Comments
Greatings formm piggest
"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."
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
'' 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, _
Plural))
'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, _
RemoveNext))))
'Leave a gap between the verses...
Console.WriteLine()
'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
Console.ReadKey()
End Sub
End Module