在窗体中变量m对应的文本框为Text1,"运行"按钮Command1对应的事件代码如下:
Private Sub Command1_Click()
Dim result As String
m = Val(Me!Text1)
result = ""
For k = 1 To m
For n = 1 To k + m - 1
If n < m - k + 1 Then
result = result & " "
Else
result = result & " *"
End If
Next n
result = result + Chr(13)
Next k
MsgBox result, , "运行结果"
End Sub
单击运行按钮后,输入m的值为5,程序的运行结果是