General FizzBuzz: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 2,226: | Line 2,226: | ||
19 |
19 |
||
Buzz</pre> |
Buzz</pre> |
||
=={{header|VBA}}== |
|||
<lang vb> |
|||
Option Explicit |
|||
Private Type Choice |
|||
Number As Integer |
|||
Name As String |
|||
End Type |
|||
Private MaxNumber As Integer |
|||
Sub Main() |
|||
Dim U(1 To 3) As Choice, i As Integer, j As Integer, t$ |
|||
MaxNumber = Application.InputBox("Enter the max number : ", "Integer please", Type:=1) |
|||
For i = 1 To 3 |
|||
U(i) = UserChoice |
|||
Next |
|||
For i = 1 To MaxNumber |
|||
t = vbNullString |
|||
For j = 1 To 3 |
|||
If i Mod U(j).Number = 0 Then t = t & U(j).Name |
|||
Next |
|||
Debug.Print IIf(t = vbNullString, i, t) |
|||
Next i |
|||
End Sub |
|||
Private Function UserChoice() As Choice |
|||
Dim ok As Boolean |
|||
Do While Not ok |
|||
UserChoice.Number = Application.InputBox("Enter the factors to be calculated : ", "Integer please", Type:=1) |
|||
UserChoice.Name = InputBox("Enter the corresponding word : ") |
|||
If StrPtr(UserChoice.Name) <> 0 And UserChoice.Number < MaxNumber Then ok = True |
|||
Loop |
|||
End Function</lang> |
|||
{{out}} |
|||
With the entry : |
|||
Max : 120 |
|||
3 : Fizz |
|||
5 : Buzz |
|||
7 : Baxx |
|||
<pre> 1 |
|||
2 |
|||
Fizz |
|||
4 |
|||
Buzz |
|||
Fizz |
|||
Baxx |
|||
8 |
|||
Fizz |
|||
Buzz |
|||
11 |
|||
Fizz |
|||
13 |
|||
Baxx |
|||
FizzBuzz |
|||
16 |
|||
17 |
|||
Fizz |
|||
19 |
|||
Buzz |
|||
FizzBaxx |
|||
22 |
|||
23 |
|||
...... |
|||
Buzz |
|||
101 |
|||
Fizz |
|||
103 |
|||
104 |
|||
FizzBuzzBaxx |
|||
106 |
|||
107 |
|||
Fizz |
|||
109 |
|||
Buzz |
|||
Fizz |
|||
Baxx |
|||
113 |
|||
Fizz |
|||
Buzz |
|||
116 |
|||
Fizz |
|||
118 |
|||
Baxx |
|||
FizzBuzz</pre> |
|||
=={{header|VBScript}}== |
=={{header|VBScript}}== |