Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language VBScript

(correct lyrics version)

Date:07/19/05
Author:exec
URL:n/a
Comments:5
Info:n/a
Score: (3.39 in 38 votes)
'99 Bottles of Beer in VBS
'coded by exec

For i = 99 To 0 Step -1
    Select Case i
        Case 1
            msg i & " Bottle of beer on the wall, " & i & " bottle of beer."
            msg "Take one down and pass it around, no more bottles of beer on the wall."
        Case 0
            msg "No more bottle of beer on the wall. No more bottles of beer..."
            msg "Go to the store and buy some more... 99 bottles of beer."
        Case Else
            msg i & " Bottles of beer on the wall, " & i & " bottles of beer."
            msg "Take one down and pass it around, " & i - 1 & " bottles of beer on the wall."
    End Select
Next

Sub msg(message)
    MsgBox message, , "99 Bottles of Beer"
End Sub

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
WSH using recursion and Microsoft AgentBob Stammers03/10/060
long versionJonathan Harrison05/17/052
Demonstrates use of "class"Bruce M. Axtens09/29/050
short versionPhilipp Winterberg04/20/050
WSF, Microsoft Agent, EN/FR/DEBob Stammers06/02/061

Comments

>>  nullplan said on 02/20/06 18:51:52

nullplan That's really bad. You get a very very big MsgBox by using that code. You know, what would be worse? One MsgBox for every 4 lines. Good luck in shutting that down. (100 MsgBoxes!! Well, it's your time, which is wasted.)

>>  exec said on 03/10/06 12:35:04

exec lol? you know this is vbs?
what else then msgboxes would you use?

>>  Bob Stammers said on 03/12/06 13:04:19

Bob Stammers If you replace the MsgBox statement with "WScript.Echo message", you'll still get a series of Message boxes if run using wscript.exe but you'll get a smooth list of lyrics if run with cscript.exe.

You could also stream the lyrics into a textfile then display using notepad.

>>  exec said on 03/27/06 09:51:08

exec Okay... You are right.
But at that time I don't knew another Method^^"

>>  Sue Harris said on 09/14/06 16:50:11

Sue Harris You need another Case for 2
When you get to i=2 your i - 1 & " bottles of beer on the wall." is still plural: 1 bottles of beer on the wall."

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!

Name:

eMail:

URL:

Security Code:
  
Comment: