回覆列表
  • 1 # 錢布斯

    三角形

    Private Sub CommandButton1_Click()

    Dim i, j, max As Integer

    max = 5

    Dim str As String

    For i = 0 To max

    For j = 0 To i * 2

    str = str & "*"

    Next j

    str = str & vbCrLf

    Next i

    MsgBox str

    End Sub

    "平行四邊形

    Private Sub CommandButton2_Click()

    Dim i, j, max As Integer

    max = 5

    Dim str As String

    For i = 0 To max

    For j = 0 To i * 2

    str = str & " "

    Next j

    For j = 0 To max * 2

    str = str & "*"

    Next j

    str = str & vbCrLf

    Next i

    MsgBox str

    End Sub  這是2個方法 分別是三角形和平行四邊形

    max是行數 你可以自行修改

      最後結果是透過msgbox顯示出來的 ,你也可以把他們顯示到textbox、Lable或者其他你喜歡的控制元件上

  • 中秋節和大豐收的關聯?
  • “虞兮虞兮奈若何”是什麼意思?