我們先來看看這個最基本的C語言版本:
#include <stdio.h>
int main () {
int i, j;
for (i = 1; i <= 9; i++)
for (j = 1; j <= 9; j++)
printf("%d x %d = %2d%s", i, j, i * j, j == 9 ? "\n" : ", ");
return 0;
}
這是VB
Dim i As Integer, j As Integer
Dim output As String
For i = 1 To 9
For j = 1 To 9
Dim v As Integer
v = i * j
output = output & CStr(i) & " * " & CStr(j) & IIf(v < 10, " = ", " = ") & CStr(v) & IIf(j = 9, vbNewLine, ""))
Next
Next
Print output