![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHTLmF52lePYmqIcgj2HPd7-bfBfTDWuuLtr_IofzvJG8xAXTzkwwADyQhWSC43ef8JFK6tK7-DP9GdcLXQH-qHfLWPKULdlbo6iOAI7_vY9xxLNUli6N9Nrc18-T9snZ2yhwbfXT2uVc/s320/%E5%B9%BE%E4%BD%95%E5%9C%96%E5%BD%A2.jpg)
Public Class Form1
'全域變數
Dim i, j As Integer
Dim output As String
'一字形
Private Sub Rdb_shape1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rdb_shape1.CheckedChanged
output = ""
For i = 1 To 10
output = output & "*"
Next
TextBox1.Text = output
End Sub
'四方形
Private Sub Rdb_shape2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rdb_shape2.CheckedChanged
output = ""
For i = 1 To 10
For j = 1 To 10
output = output & "*"
Next j
output = output & vbNewLine
Next i
TextBox1.Text = output
End Sub
'三角形
Private Sub Rdb_shape3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Rdb_shape3.CheckedChanged
output = ""
For i = 1 To 10
For j = 1 To i
output = output & "*"
Next j
output = output & vbNewLine
Next i
TextBox1.Text = output
End Sub
'倒三角形
Private Sub Rdb_shape4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rdb_shape4.CheckedChanged
output = ""
For i = 10 To 1 Step -1
For j = 1 To i
output = output & "*"
Next j
output = output & vbNewLine
Next i
TextBox1.Text = output
End Sub
'正三角形
Private Sub Rdb_shape5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rdb_shape5.CheckedChanged
Dim k, numofstars As Integer
output = ""
numofstars = 1
For i = 1 To 19 Step 2
For j = 19 To i Step -2
output = output & " "
Next j
For k = 1 To numofstars
output = output & "*"
Next k
numofstars = numofstars + 2
output = output & vbNewLine
Next i
TextBox1.Text = output
End Sub
'結束
Private Sub Bt_end_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_end.Click
End
End Sub
End Class
留言