Thought Sharing

Monday, March 23, 2009

Program in Visual Basic to generate the following pattern of stars:

Program in Visual Basic to generate the following pattern of stars:

* * * * *
* * * *
* * *
* *
*

Step-1 Drag and drop a command button on the form. Set its caption to ‘Print’
Step-2 Write the following code on the click event of command button

Private Sub Command1_Click()

Dim i As Integer
Dim j As Integer
For i = 5 To 1 Step -1
For j = 1 To i
Print " * ";
Next j
Print
Next i

End Sub