vb 打印空心菱形问题!!请高手帮忙写一下!谢谢!

2024-12-26 16:27:13
推荐回答(1个)
回答1:

创建一个按钮commmand1
复制以下代码:

Option Explicit

Private Sub Command1_Click()
Dim i As Integer, n As Integer
Dim j As Integer
For i = 1 To 7
Print Tab(20 - i);
For j = 1 To 2 * i - 1
If j = 1 Or j = 2 * i - 1 Then
Print "*";
Else
Print " ";
End If
Next
Print
Next
n = i - 2
For i = n To 1 Step -1
Print Tab(20 - i);
For j = 1 To 2 * i - 1
If j = 1 Or j = 2 * i - 1 Then
Print "*";
Else
Print " ";
End If
Next
Print
Next
End Sub