Create a Visual Basic application that every time I press button1, it will displ
ID: 3829079 • Letter: C
Question
Create a Visual Basic application that every time I press button1, it will display triable asterisk according to four patterns in a textbox. Must use LOOP STRUCTURES. The height of the triangle needs to be 21 rows.
For example:
Pattern A
*
**
***
****
*****
******
*******
********
*********
**********
Pattern B
**********
*********
********
*******
******
*****
****
***
**
*
Pattern C
**********
*********
********
*******
******
*****
****
***
**
*
Pattern D
*
**
***
****
*****
******
*******
********
*********
**********
Explanation / Answer
As per Question Pattern A & D / B & C are Same.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'PATTERN A
Dim i As Integer
For i = 1 To 10
ListBox1.Items.Add(StrDup(i, "*"))
Console.WriteLine()
Next i
'PATTERN B
Dim i As Integer
For i = 10 To 1 Step -1
ListBox1.Items.Add(StrDup(i, "*"))
Console.WriteLine()
Next i
'PATTERN C
Dim i As Integer
For i = 10 To 1 Step -1
ListBox1.Items.Add(StrDup(i, "*"))
Console.WriteLine()
Next i
'PATTERN D
Dim i As Integer
For i = 1 To 10
ListBox1.Items.Add(StrDup(i, "*"))
Console.WriteLine()
Next i
End Sub