99 Bottles of Beer/Basic: Difference between revisions

no edit summary
No edit summary
 
(35 intermediate revisions by 12 users not shown)
Line 5:
[[99 Bottles of Beer]] done in any of the BASIC-languages.
__toc__
 
=={{header|BASIC}}==
==={{header|QuickBASIC}}===
{{works with|QuickBASIC|4.5}}
====Sound====
This version plays the tune 100 times while printing out the lyrics (not synchronized).
<lang qbasic>PLAY "<"
FOR x = 99 TO 0 STEP -1
PRINT x; "bottles of beer on the wall"
PRINT x; "bottles of beer"
PRINT "Take one down, pass it around"
PRINT x-1; "bottles of beer on the wall"
PRINT
PLAY "e-8e-8e-8<b-8b-8b-8>e-8e-8e-8e-4"'X bottles of beer on the wall
PLAY "f8f8f8c8c8c8f4"'X bottles of beer
PLAY "d4d8d8 N0 d8d8d8d4"'take one down, pass it around
PLAY "<a+8a+8a+8>c8c8d8d+8d+8d+8d+4"'X-1 bottles of beer on the wall
NEXT x</lang>
 
====Text====
<lang qbasic>FOR x = 99 TO 1 STEP -1
PRINT x; "bottles of beer on the wall"
PRINT x; "bottles of beer"
PRINT "Take one down, pass it around"
PRINT x-1; "bottles of beer on the wall"
PRINT
NEXT x</lang>
 
==={{header|Applesoft BASIC}}===
<langsyntaxhighlight Applesoft BASIClang="qbasic">H$ = "HELLO, WORLD!":B$ = " BOTTLES OF BEER":N$ = CHR$ (13):W$ = " ON THE WALL" + N$: FOR B = 99 TO 1 STEP - 1: PRINT B;B$W$B" "B$N$"TAKE ONE DOWN, PASS IT AROUND"N$B - 1;B$W$: NEXT </langsyntaxhighlight>
 
==={{header|BaCon}}===
With lyrics and punctuation taken from the 99-bottles-of-beer.net site.
<langsyntaxhighlight lang="freebasic">' 99 bottles of beer on the wall
DECLARE counter$
DECLARE bottle$
Line 66 ⟶ 40:
PRINT counter$, bottle$, ofbeer$, onthewall$ FORMAT "%s %s %s %s.\n"
IF bottles > 0 THEN PRINT
NEXT</langsyntaxhighlight>
 
==={{header|BASIC256}}===
<langsyntaxhighlight BASIC256lang="basic256">#length of querter and eight note in ms
n4 = 1000 * 60 / 80 / 4
n8 = n4 / 2
Line 102 ⟶ 76:
print
next x
</syntaxhighlight>
</lang>
 
==={{header|BBC BASIC}}===
'''Versión más clásica'''
<syntaxhighlight lang="bbcbasic">REM 99 bottles of beer song BBC BASIC version
REM original code by Stelio Passaris (stelio.net)
:
a$=" bottle"
s$="s"
b$=" of beer"
c$=" on the wall..."
t$="Take one down and pass it around,"
:
VDU14:REM habilita el modo de paginación; pulsa shift para avanzar página.
FOR i% = 99 TO 1 STEP -1
IF i% = 1 THEN s$=""
IF i% < 99 THEN PRINT;i%;a$;s$;b$;c$;"."'
PRINT;i%;a$;s$;b$;c$;","'i%;a$;s$;b$;"."'t$
NEXT i%
PRINT"no more";a$;"s";b$;c$;"."
PRINT'"No more bottles of beer on the wall,"
PRINT"no more bottles of beer."
PRINT"Go to the store and buy some more,"
PRINT"99 bottles of beer on the wall."
VDU15:REM deshabilita el modo de paginación</syntaxhighlight>
 
Alternative version:
<lang bbcbasic>
 
<syntaxhighlight lang="bbcbasic">
N_Bottles = 99
Line 139 ⟶ 137:
END
</syntaxhighlight>
</lang>
 
==={{header|bootBASIC}}===
In bootBASIC lines are limited to 19 characters.
<syntaxhighlight lang="BASIC">
5 a=99
10 print a ;
20 print " bottle";
22 if a-1 print "s";
24 print " ";
30 print "of beer ";
40 print "on the ";
50 print "wall!"
60 print a ;
70 print " bottle";
72 if a-1 print "s";
74 print " ";
80 print "of beer!"
90 print "Take one ";
100 print "down, pass";
110 print " it around!"
115 a=a-1
120 print a ;
130 print " bottle";
132 if a-1 print "s";
134 print " ";
140 print "of beer ";
150 print "on the ";
160 print "wall!"
170 print
180 if a goto 10
</syntaxhighlight>
 
==={{header|Commander X16 BASIC}}===
<syntaxhighlight lang="BASIC">
10 PSGINIT
20 PSGPLAY 0, "T220L4"
30 FOR Z=99 TO 1 STEP -1
40 PRINT Z; "BOTTLE";
50 IF Z <> 1 THEN PRINT "S";
60 PRINT " ";
70 PRINT "OF BEER ON THE WALL!"
80 PSGPLAY 0,"GGGDDDGGGG2."
90 PRINT Z; "BOTTLE";
100 IF Z <> 1 THEN PRINT "S";
110 PRINT " ";
120 PRINT "OF BEER!"
130 PSGPLAY 0,"AAAEEES0A2.A2.S1"
140 PRINT " TAKE ONE DOWN"
150 PSGPLAY 0,"F+2F+F+2."
160 PRINT " PASS IT AROUND"
170 PSGPLAY 0,"F+F+F+F+2."
180 PRINT Z-1; "BOTTLE";
190 IF Z <> 2 THEN PRINT "S";
200 PRINT " ";
210 PRINT "OF BEER ON THE WALL!"
220 PSGPLAY 0,"DDDDEF+GGGG2."
230 PRINT
240 NEXT Z
</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{works with|GW-BASIC}}
<syntaxhighlight lang="qbasic">10 cls
20 s$ = "s"
30 for bottles = 99 to 1 step -1
40 print bottles "bottle" s$ " of beer on the wall, "
50 print bottles "bottle" s$ " of beer."
60 print "Take one down and pass it around, "
70 if bottles = 2 then s$ = ""
80 if bottles > 1 then print (bottles-1)"bottle" s$ " of beer on the wall..." else print "no more bottles of beer on the wall..."
90 print
100 next bottles
110 print "No more bottles of beer on the wall,"
120 print "no more bottles of beer."
130 print "Go to the store and buy some more,"
140 print "99 bottles of beer on the wall."
150 end</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
You may need to remove the semicolon on line 20 when executing on the VIC-20. Also, this looks best on the machines with 40 or more columns.
 
<syntaxhighlight lang="freebasic">10 dim bo$(2):bo$(0)="bottle":bo$(1)="bottles"
<lang FreeBasic>
10 dim bo$(2):bo$(0)="bottle":bo$(1)="bottles"
15 print chr$(147);chr$(14);"99 Bottles of Beer Song"
20 print:print "Start with how many bottles";
Line 163 ⟶ 238:
130 if k$="q" then end
135 rem move to next verse
140 print:next c</syntaxhighlight>
 
</lang>
==={{header|Craft Basic}}===
<syntaxhighlight lang="basic">'99 bottles of beer on the wall
 
for beer = 99 to 1 step - 1
 
if beer > 1 then
 
print beer, " bottles of beer on the wall."
print beer, " bottles of beer!"
 
endif
 
if beer = 1 then
 
print beer, " bottle of beer on the wall."
print "1 more bottle of beer!"
 
endif
 
print "take one down and pass it around..."
 
wait
 
next beer
 
alert "All out of beer!"
 
end</syntaxhighlight>
 
==={{header|Creative Basic}}===
====window version====
<langsyntaxhighlight Creativelang="creative Basicbasic">DEF Win:WINDOW
DEF Close:CHAR
DEF ScreenSizeX,ScreenSizeY:INT
Line 309 ⟶ 412:
NEXT X
 
RETURN</syntaxhighlight>
</lang>
====console only version====
Rather quickly written and dirty.
<langsyntaxhighlight Creativelang="creative Basicbasic">REM Using the ESC key to exit will not work in console programs under Windows 95/98 or ME.
 
DECLARE SingWallLn()
Line 423 ⟶ 525:
END
 
RETURN</syntaxhighlight>
</lang>
 
==={{header|FBSL}}===
This is a OO version, using FBSL v3.5 Beta
<langsyntaxhighlight lang="qbasic">#AppType Console
 
Class Wall
Line 488 ⟶ 589:
while BeerSong.Sing() <> 99
end while
</syntaxhighlight>
</lang>
 
==={{header|FreeBASIC}}===
==== Normal version ====
<lang freebasic>' FB 1.05.0 Win64
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Dim As Integer bottles = 99
Line 511 ⟶ 613:
 
Print "Press any key to sleep it off"
Sleep</langsyntaxhighlight>
 
==== Code golf ====
<syntaxhighlight lang="freebasic">Var b=" bottle",s="s",f=" of beer",w=" on the wall",_
t="Take one down and pass it around, ",n="o more",p="."
For a As Byte=99 To 1 Step-1
?Str(a);b;*Iif(a>1,@s,0);f;w;",";a;b;*Iif(a>1,@s,0);f;p
If a>1 Then ?t;Str(a-1);b;*Iif(a>2,@s,0);f;w;p:?
Next
?t;"n";n;b;s;f;w;p:?:?"N";n;b;s;f;w;", n";n;b;s;f;p
?"Go to the store and buy some more, 99";b;s;f;w;p
Sleep</syntaxhighlight>
 
==={{header|FUZE BASIC}}===
<langsyntaxhighlight lang="qbasic">CLS
DIM s$(1)
READ b,s$(0),s$(1),a$,b$,c$,d$,e$,f$
Line 525 ⟶ 638:
DATA 99,"","s"," bottle"," of beer"," on the wall. ","Take one down, pass it around. "
DATA "No more","Go to the store and buy some more. 99"
END</langsyntaxhighlight>
 
==={{header|Integer GW-BASIC}}===
Just a basic loop counting down to one. No big deal. Note that at BOTTLES=1, it is not
grammatically correct.
 
<syntaxhighlight lang="qbasic">10 FOR BOTTLES = 99 TO 1 STEP -1
20 PRINT BOTTLES " bottles of beer on the wall"
30 PRINT BOTTLES " bottles of beer"
40 PRINT "Take one down, pass it around"
50 PRINT BOTTLES-1 " bottles of beer on the wall"
60 NEXT BOTTLES
</syntaxhighlight>
 
==={{header|Integer BASIC}}===
IMPORTANT NOTE: Integer BASIC was written (and hand-assembled by Woz himself)
for the Apple 1 and original Apple 2.
Line 534 ⟶ 658:
The UPPER-CASE output of this example accurately represents the only reasonable solution for those target devices, and therefore cannot be "fixed" for mixed case, only deleted.
 
<langsyntaxhighlight Integerlang="integer BASICbasic">E000G (APPLE II)
E000R (APPLE I)
10 REM -------------------------
Line 561 ⟶ 685:
80 PRINT " BOTTLE";: IF B#1 THEN PRINT "S";: PRINT " OF BEER";
90 IF W#1 THEN PRINT " ON THE WALL";: IF W THEN PRINT ".": NEXT W,B: END
RUN</langsyntaxhighlight>
 
==={{header|Liberty BASIC}}===
<langsyntaxhighlight lang="lb">For bottles = 99 To 1 Step -1
song$ = song$ + str$(bottles) + " bottle"
If (bottles > 1) Then song$ = song$ + "s"
Line 576 ⟶ 700:
+ chr$(13) + chr$(10) + "Go to the store and buy some more, 99 bottles of beer on the wall."
 
Print song$</langsyntaxhighlight>
 
==={{header|Microsoft Small Basic}}===
<syntaxhighlight lang="microsoftsmallbasic">
 
<lang microsoftsmallbasic>
For n = 99 To 1 Step -1
If n = 1 Then
Line 598 ⟶ 721:
TextWindow.WriteLine("")
EndFor
</syntaxhighlight>
</lang>
 
==={{header|MSXMinimal BasicBASIC}}===
{{trans|BBC BASIC}}
The cases of 99 bottles and of 1 bottle are extracted from the loop. The variable <code>S$</code> is replaced by litterals, <code>T$</code> is divided into two variables (In Minimal BASIC strings assignable to string variables may contain up to 18 chars).
<syntaxhighlight lang="gwbasic">
10 REM 99 Bottles of Beer
20 LET A$ = " bottle"
30 LET B$ = " of beer"
40 LET C$ = " on the wall..."
50 LET T$ = "Take one down and"
60 LET U$ = " pass it around,"
70 REM 99 bottles
80 PRINT 99; A$; "s"; B$; C$; ","
90 PRINT 99; A$; "s"; B$; "."
100 PRINT T$; U$
110 FOR I = 98 TO 2 STEP -1
120 PRINT I; A$; "s"; B$; C$; "."
130 PRINT
140 PRINT I; A$; "s"; B$; C$; ","
150 PRINT I; A$; "s"; B$; "."
160 PRINT T$; U$
170 NEXT I
180 REM 1 bottle
190 PRINT 1; A$; B$; C$; "."
200 PRINT
210 PRINT 1; A$; B$; C$; ","
220 PRINT 1; A$; B$; "."
230 PRINT T$; U$
240 PRINT "no more"; A$; "s"; B$; C$; "."
250 PRINT
260 PRINT "No more bottles of beer on the wall,"
270 PRINT "no more bottles of beer."
280 PRINT "Go to the store and buy some more,"
290 PRINT "99 bottles of beer on the wall."
300 END</syntaxhighlight>
 
==={{header|MSX Basic}}===
<lang MSXBasic>
<syntaxhighlight lang="qbasic">10 FOR X = 99 TO 1 STEP -1
20 PRINT X; "bottles of beer on the wall"
30 PRINT X; "bottles of beer"
Line 609 ⟶ 765:
50 PRINT X-1; "bottles of beer on the wall"
60 PRINT
70 NEXT X</syntaxhighlight>
</lang>
 
==={{header|OxygenBasic}}===
<langsyntaxhighlight lang="qbasic">int x=99
int x=99
string cr,tab,pr,bottles,bottlem,remain
cr=chr(13) chr(10)
Line 641 ⟶ 795:
next
'
putfile "t.txt",pr </syntaxhighlight>
</lang>
 
==={{header|PowerBASIC}}===
<langsyntaxhighlight PowerBasiclang="powerbasic">#COMPILE EXE
#DIM ALL
 
Line 674 ⟶ 827:
CON.INPUT("Press any key to sleep it off",done$)
 
END FUNCTION</langsyntaxhighlight>
 
==={{header|PureBasic}}===
====Normal version====
<langsyntaxhighlight PureBasiclang="purebasic">If OpenConsole()
Define Bottles=99
While Bottles
Line 690 ⟶ 843:
PrintN(#CRLF$+#CRLF$+"Press ENTER to exit"):Input()
CloseConsole()
EndIf</langsyntaxhighlight>
 
====An object-oriented solution====
<langsyntaxhighlight PureBasiclang="purebasic">Prototype Wall_Action(*Self, Number.i)
 
Structure WallClass
Line 751 ⟶ 904:
CloseConsole()
EndIf
EndIf</langsyntaxhighlight>
 
==={{header|QB64}}===
<lang vb>''CBTJD'': 2020./03./08
* Manages grammatical support for "1 bottle of beer" and "No more bottles of beer".
A$ = "bottle": B$ = " of beer": C$ = " on the wall": D$ = " Take one down, pass it around": E$ = " No more "
<syntaxhighlight lang="vb">A$ = "bottle": B$ = " of beer": C$ = " on the wall": D$ = " Take one down, pass it around": E$ = " No more "
FOR B = 99 TO 1 STEP -1
S$ = STRING$(ABS(B > 1), "s")
Line 765 ⟶ 919:
END SELECT
PRINT
NEXT</syntaxhighlight>
NEXT
 
</lang>
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">suffix$ = "s"
FOR bottles = 4 TO 1 STEP -1
PRINT STR$(bottles) + " bottle" + suffix$ + " of beer on the wall, ";
PRINT STR$(bottles) + " bottle" + suffix$ + " of beer."
PRINT "Take one down and pass it around, ";
IF bottles > 1 THEN
IF bottles = 2 THEN suffix$ = ""
PRINT STR$(bottles - 1) + " bottle" + suffix$ + " of beer on the wall..."
ELSE
PRINT "no more bottles of beer on the wall..."
END IF
PRINT
NEXT bottles
 
PRINT "No more bottles of beer on the wall, no more bottles of beer."
PRINT "Go to the store and buy some more, 99 bottles of beer on the wall."
END</syntaxhighlight>
 
==={{header|QuickBASIC}}===
{{works with|QuickBASIC|4.5}}
====Sound====
This version plays the tune 100 times while printing out the lyrics (not synchronized).
<syntaxhighlight lang="qbasic">PLAY "<"
FOR x = 99 TO 0 STEP -1
PRINT x; "bottles of beer on the wall"
PRINT x; "bottles of beer"
PRINT "Take one down, pass it around"
PRINT x-1; "bottles of beer on the wall"
PRINT
PLAY "e-8e-8e-8<b-8b-8b-8>e-8e-8e-8e-4"'X bottles of beer on the wall
PLAY "f8f8f8c8c8c8f4"'X bottles of beer
PLAY "d4d8d8 N0 d8d8d8d4"'take one down, pass it around
PLAY "<a+8a+8a+8>c8c8d8d+8d+8d+8d+4"'X-1 bottles of beer on the wall
NEXT x</syntaxhighlight>
 
====Text====
<syntaxhighlight lang="qbasic">FOR x = 99 TO 1 STEP -1
PRINT x; "bottles of beer on the wall"
PRINT x; "bottles of beer"
PRINT "Take one down, pass it around"
PRINT x-1; "bottles of beer on the wall"
PRINT
NEXT x</syntaxhighlight>
 
==={{header|REALbasic}}===
Place the following in the "open" event of a console application.
<langsyntaxhighlight lang="vb">dim bottles as Integer = 99
While bottles > 0
Print(str(bottles) + " bottles of beer on the wall")
Line 777 ⟶ 977:
bottles = bottles - 1
Print(str(bottles) + " bottles of beer on the wall")
Wend</langsyntaxhighlight>
 
==={{header|Run BASIC}}===
<langsyntaxhighlight Runbasiclang="runbasic">b$ = " bottles"
for bottles = 99 To 1 Step -1
If (bottles = 1) then b$ = " bottle"
Line 791 ⟶ 991:
print bottles - 1;b$;" of beer on the wall.";chr$(10)
end if
next bottles</langsyntaxhighlight>
 
==={{header|Sinclair ZX81 BASIC}}===
Scrolls after each line so doesn't run out of screen space and stop prematurely!
<syntaxhighlight lang="basic">10 FOR N=99 TO 1 STEP -1
20 SCROLL
30 PRINT STR$(N)+" BOTTLE"+("S" AND N<>1)+" OF BEER ON THE WALL"
40 SCROLL
50 PRINT STR$(N)+" BOTTLE"+("S" AND N<>1)+" OF BEER"
60 SCROLL
70 PRINT "TAKE ONE DOWN, PASS IT AROUND"
80 SCROLL
90 PRINT STR$(N-1)+" BOTTLE"+("S" AND N<>2)+" OF BEER ON THE WALL"
100 SCROLL
110 NEXT N</syntaxhighlight>
 
==={{header|smart BASIC}}===
<langsyntaxhighlight lang="qbasic">READ b,s$(0),s$(1),a$,b$,c$,d$,e$,f$
g$ = CHR$(10)
WHILE b > 0
Line 813 ⟶ 1,027:
DATA 99,"","s"," bottle"," of beer"," on the wall. ","Take one down, pass it around. "
DATA "No more","Go to the store and buy some more. 99"
END</langsyntaxhighlight>
 
==={{header|TI-83 BASIC}}===
<langsyntaxhighlight lang="ti83b">PROGRAM:BEER
:For(I,99,1,-1)
:Disp I
Line 828 ⟶ 1,042:
:Disp "BOTTLES OF BEER"
:Disp "ON THE WALL."
:End</syntaxhighlight>
:End
</lang>
 
 
==={{header|TI-89 BASIC}}===
<langsyntaxhighlight lang="ti89b">Prgm
Local i,plural,clockWas,t,k,wait
"s" → plural
Line 879 ⟶ 1,091:
ClockOff
ENdIf
EndPrgm</langsyntaxhighlight>
 
==={{header|True BASICTiny_Basic}}===
{{works with|TinyBasic}}
<lang basic>
<syntaxhighlight lang="basic">100 LET N=99
! TrueBASIC v6.007
105 GOSUB 120
110 IF N>0 THEN GOTO 105
115 END
120 GOSUB 155
125 GOSUB 175
130 PRINT "Take one down, pass it round"
135 LET N=N-1
140 GOSUB 155
145 PRINT ""
150 RETURN
155 IF N=0 THEN PRINT "No more bottles of beer on the wall"
160 IF N=1 THEN PRINT N," bottle of beer on the wall"
165 IF N>1 THEN PRINT N," bottles of beer on the wall"
170 RETURN
175 IF N=0 THEN PRINT "No more bottles of beer"
180 IF N=1 THEN PRINT N," bottle of beer"
185 IF N>1 THEN PRINT N," bottles of beer"
190 RETURN</syntaxhighlight>
 
==={{header|True_BASIC}}===
<syntaxhighlight lang="basic">! TrueBASIC v6.007
 
LET bottles = 99
Line 906 ⟶ 1,139:
PRINT "Press any key to sleep it off"
GET KEY done
END</syntaxhighlight>
END
</lang>
 
==={{header|Visual Basic}}===
<langsyntaxhighlight lang="vb">Sub Main()
Const bottlesofbeer As String = " bottles of beer"
Const onthewall As String = " on the wall"
Line 942 ⟶ 1,174:
Debug.Print "Go to the store, buy some more"
Debug.Print "99" & bottlesofbeer & onthewall
End Sub</langsyntaxhighlight>
 
==={{header|Visual Basic .NET}}===
Line 948 ⟶ 1,180:
 
====Classic====
<langsyntaxhighlight lang="vbnet">Module Module1
Sub Main()
Dim Bottles As Integer
Line 967 ⟶ 1,199:
Next
End Sub
End Module</langsyntaxhighlight>
 
====String interpolation====
<langsyntaxhighlight lang="vbnet">Module Program
Function Plural(count As Integer) As String
Return If(count = 1, "", "s")
Line 984 ⟶ 1,216:
Next
End Sub
End Module</langsyntaxhighlight>
 
====Mental mutilation beyond hope of regeneration====
<langsyntaxhighlight lang="vbnet">Option Explicit Off
Option Strict Off
 
Line 1,015 ⟶ 1,247:
If i > 0 Then GoTo START
End Sub
End Module</langsyntaxhighlight>
 
====Python====
<langsyntaxhighlight lang="vbnet">Option Strict Off
 
Module Program
Line 1,025 ⟶ 1,257:
Console.Write(String.Join(vbLf,Enumerable.Range(1,99).Reverse.Select(Function(x)s(x)+a+b+s(x)+a+vbLf+c+s(x-1)+a+b)))
End Sub
End Module</langsyntaxhighlight>
 
====With sound====
Line 1,044 ⟶ 1,276:
 
Options and imports statements (all parts must be in one file):
<langsyntaxhighlight lang="vbnet">Option Explicit On
Option Infer On
Option Strict On
Line 1,050 ⟶ 1,282:
Imports System.Globalization
Imports System.Runtime.InteropServices
Imports System.Threading</langsyntaxhighlight>
 
Helper to parse command-line arguments:
<langsyntaxhighlight lang="vbnet">
Module ArgHelper
ReadOnly _ArgDict As New Dictionary(Of String, String)()
Line 1,091 ⟶ 1,323:
End If
End Sub
End Module</langsyntaxhighlight>
 
Program:
<langsyntaxhighlight lang="vbnet">Module Program
Function GetNumberSyllables(n As Integer) As IEnumerable(Of String)
Static getTensPrefix As Func(Of Integer, IEnumerable(Of String)) =
Line 1,288 ⟶ 1,520:
End Sub
End Module
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,327 ⟶ 1,559:
 
====Concurrent====
<langsyntaxhighlight lang="vbnet">Module Program
Function Plural(count As Integer) As String
Return If(count = 1, "", "s")
Line 1,343 ⟶ 1,575:
End Sub)
End Sub
End Module</langsyntaxhighlight>
 
{{out}}
Line 1,372 ⟶ 1,604:
 
====Less concurrent====
<langsyntaxhighlight lang="vbnet">Module Program
Function Plural(count As Integer) As String
Return If(count = 1, "", "s")
Line 1,391 ⟶ 1,623:
End Sub)
End Sub
End Module</langsyntaxhighlight>
 
{{out}}
Line 1,416 ⟶ 1,648:
...</pre>
 
====<s>More</s>D<s> </s>R<s>con</s>U<s>current</s>NKconcurrent====
<langsyntaxhighlight lang="vbnet">Module Program
Function Plural(count As Integer) As String
Return If(count = 1, "", "s")
Line 1,442 ⟶ 1,674:
End Sub)
End Sub
End Module</langsyntaxhighlight>
 
{{out}}
Line 1,505 ⟶ 1,737:
{{trans|Microsoft Small Basic}}
{{works with|Windows XBasic}}
<syntaxhighlight lang="xbasic">PROGRAM "99bottles"
<lang xbasic>
PROGRAM "99bottles"
VERSION "0.0001"
 
Line 1,531 ⟶ 1,762:
NEXT n@@
END FUNCTION
END PROGRAM</syntaxhighlight>
 
</lang>
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">b$ = " bottles"
for bottles = 99 to 1 step -1
if (bottles = 1) then b$ = " bottle" : fi
print bottles, b$, " of beer on the wall, "
print bottles , b$, " of beer"
print "Take one down, pass it around, "
if bottles = 1 then
print "no more bottles of beer on the wall.\n"
else
print bottles - 1, b$, " of beer on the wall."
print
end if
next bottles
end</syntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
<langsyntaxhighlight lang="zxbasic">10 DEF FN n$(b)="no more" AND NOT b
20 DEF FN m$(b)=(STR$ b) AND b
30 DEF FN o$(b)="s" AND (b>1)
Line 1,550 ⟶ 1,797:
140 PRINT
150 NEXT i
160 PRINT "Go to the store and buy some more, 99 bottles of beer on the wall."</syntaxhighlight>
</lang>
 
=={{header|VBA}}==
Line 1,557 ⟶ 1,803:
plus a Static variable to count the number of bottles emptied.
 
<langsyntaxhighlight lang="vb">Public Function countbottles(n As Integer, liquid As String) As String
countbottles = IIf(n > 1, Format$(n), IIf(n = 0, "no more", "one")) & " bottle" & IIf(n = 1, "", "s") & " of " & liquid
End Function
Line 1,578 ⟶ 1,824:
End If
End Sub</langsyntaxhighlight>
 
Usage: type "drink 99" in the Immediate window of the VBA editor. If you're not a beer drinker, you can specify your own favourite drink as the second argument; for example:
Line 1,603 ⟶ 1,849:
no more bottles of Johnnie Walker
go to the store and buy some more
3 bottles of Johnnie Walker on the wall</pre>
 
</pre>
 
=={{header|VBScript}}==
===Simple Method===
<langsyntaxhighlight lang="vb">sub song( numBottles )
dim i
for i = numBottles to 0 step -1
Line 1,645 ⟶ 1,889:
end function
 
song 3</langsyntaxhighlight>
{{Out}}
<pre>3 bottles of beer on the wall
Line 1,676 ⟶ 1,920:
and replacing the code with the result of its evaluation.
 
<langsyntaxhighlight lang="vb">function pluralBottles( n )
select case n
case 1
Line 1,733 ⟶ 1,977:
end sub
 
sing 3</langsyntaxhighlight>