Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
n = Val(Text1.Text) + 1
Dim a(9, 9) As Integer
For i = 0 To n - 1
a(i, 0) = 1
Next i
For i = 1 To n - 1
For j = 1 To i
If i = j Then a(i, j) = 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j
Next i
For i = 0 To n - 1
For j = 0 To i
Picture1.Print Tab(30 - 3 * i + 6 * j); a(i, j);
Next j
Picture1.Print
Next i
End If
End Sub
结果如图: