这个VB程序怎么编?

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:17:25
*
***
*****
*******
*****
***
*
怎么输出来呀?请教高手,万分紧急
*
***
*****
***
*

VB 菱形

Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim n As Integer

n = 4
For i = 1 To n
Print Space$(n - i);
For j = 1 To (i * 2 - 1)
Print "*";
Next j
Print
Next i

For i = n - 1 To 1 Step -1
Print Space$(n - i);
For j = 1 To (i * 2 - 1)
Print "*";
Next j
Print
Next i

End Sub

Print "*"
Print "***"
Print "*****"
Print "*******"
Print "*****"
Print "***"
Print "*"

这是最简单的输出在窗体上的方法...
如果要用for循环就判断输出次数到4之前是递增之后递减 循环7次即可...

for i=1 to 4
for j=1 to 2*i-1
print "*";
next
print
next
for m=4 to 1 step -1
for n=1 to 2*m-1
print "*";
next
print
next