怎样用VB程序设计出如下带*的倒三角?

******* ***** *** *
2024-11-22 00:29:31
推荐回答(2个)
回答1:

可运行代码为:
Const s = "倒三角形"
Private Sub Command1_Click()
Dim N As Integer
Do
N = InputBox("你一共准备输出几行?", s, 5)
If N > 50 Then
MsgBox "你的行数也太多了吧?看着我就累了。", vbExclamation, s
ElseIf N < 1 Then
MsgBox "这怎么能搞成?你见过" & N & "行的三角形?", vbCritical, s
Else
Exit Do
End If
Loop
最长星星数 = N + N + 1
For i = 1 To N
Print Tab(i); String(最长星星数 - i - i, "*")
Next i
End Sub

实质有用的代码仅仅是:
最长星星数 = N + N + 1
For i = 1 To N
Print Tab(i); String(最长星星数 - i - i, "*")
Next i

回答2:

Private Sub Form_Load()
Form1.AutoRedraw = True
Print "*******"
Print " *****"
Print " ***"
Print " *"
End Sub