Private Sub Form_Click()
Dim i As Integer, j As Integer
For i = 1 To 9
If i <= 5 Then
Print Space(5 - i);
For j = 1 To (i - 1) * 2 + 1
If j = (i - 1) * 2 + 1 Then
Print CStr(i)
Else
Print CStr(i);
End If
Next j
Else
Print Space(i - 5);
For j = 1 To (10 - i - 1) * 2 + 1
If j = (10 - i - 1) * 2 + 1 Then
Print CStr(i)
Else
Print CStr(i);
End If
Next j
End If
Next i
'点击窗口任意位置即可
End Sub
for i= 1 to 9
print space( abs(5-i) );
for j=1 to (2* (5-abs(5-i)) -1)
print cstr(i);
next
print
next
代码如下
Private Sub Command1_Click()
Dim a(1 To 9)
For i = 1 To 9:
Print Tab(30 - 3 * i);
For j = 1 To i:
Print j; m;
Next
Print ;
Next
For n = 1 To 8
Print Tab(30);
For m = n To 1 Step -1
Print m;
Next
Print
Next
End Sub
Private Sub Command1_Click()
Dim i As Byte, j As Byte, n As Byte
Do
n = InputBox("n=", "请输入n的值")
Loop While n < 1 Or n > 9
For i = 1 To n
Print Space(Abs(5 - i));
For j = 1 To (2 * (5 - Abs(5 - i)) - 1)
Print CStr(i);
Next j
Next i
End Sub