Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, July 30, 2011

VB-75 : Displays shape according to the entered value

Write a VB program in which function accepts the integer value from the user and displays the diamond shape according to the user input.


(A)Program Design :
 
(B) Property(Controls Used) :
  • A Label with Caption "Enter Number"
  • A Text Box to enter number
  • A command Button with Caption "Display"
  • A List Box to display Shape
(C) Attaching Code to the Object :
Private Sub Command1_Click()
Dim i
Dim j
Dim NumLines, str

NumLines = CInt(Text1)
List1.Clear

For i = 0 To NumLines / 2
For j = i To NumLines / 2 + 1
str = str & ""
Next

For j = 0 To i Step 1
str = str & "**"
Next

List1.AddItem (str)
str = ""
Next

For i = 1 To NumLines / 2
For j = 0 To i + 1
str = str & " "
Next

For j = i To NumLines / 2
str = str & "**"
Next

List1.AddItem (str)
str = ""
Next

End Sub


(D) Output :
(E) Errors :
If found any errors while running your VB program, please click this link   Possible Errors while running VB Programs to get a solution.


===============================================
===============================================

No comments: