https://v.qq.com/x/page/u094113823o.html
文字讲解:
刘金玉的零基础VB教程076期:
如何打印数字菱形图案
输出目标
1
121
12321
1234321
12321
121
1
类型声明符号
Long &
Integer %
String $
Double #
Single !
课堂总结
1、要理解星号菱形作为基础
2、理解中间数的特点中间数=最大数量/2 1
界面:
源代码:
代码语言:javascript复制Private Sub Form_Load()
Show
FontSize = 18
Dim i&, j&, n&
n = 5
For i = 0 To n Step 1
'输出空格
For j = 1 To n - i Step 1
Print " ";
Next j
Dim k&
k = 1
'输出数字
For j = 1 To 2 * i 1 Step 1
Print Format(k, "@");
If j <= Int((2 * i 1) / 2) Then
k = k 1
Else
k = k - 1
End If
Next j
Print
Next i
'下半部分
For i = 0 To n - 1 Step 1
'输出空格
For j = 0 To i Step 1
Print " ";
Next j
Dim p&
p = 1
'输出数字
For j = 1 To 2 * (n - i) - 1 Step 1
Print CStr(p);
If j <= Int((2 * (n - i) - 1) / 2) Then
p = p 1
Else
p = p - 1
End If
Next j
Print
Next i
End Sub