Visual Objects
Visual Objects
Visual Objects
• List1.AddItem 3
• Label1.Caption = List1.ListCount
• End Sub
example
• Private Sub Form_Load()
• list1.AddItem 1
list1.AddItem 2
list1.AddItem 3
list1.AddItem 4
list1.AddItem 5
list1.AddItem 6
• End Sub
Adding items to a listbox using textbox
• Private Sub Command1_Click()
• List1.AddItem Text1.Text
• Text1.Text = ""
• End Sub
Working with listbox
• Form1.BackColor = vbRed
• Form1.BackColor = vbGreen
• Else
• Form1.BackColor = vbBlue
• End If
•
• Private Sub cmdCheck_Click()
• If optWindows.Value = True Then
• Print "Windows is selected"
• ElseIf optLinux.Value = True Then
• Print "Linux is selected"
• ElseIf optMac.Value = True Then
• Print "Mac is selected"
• End If
• End Sub
Frame control (frm)
• Frame is a container control as the Frame control
is used as a container of other controls.
• The controls that are on the frame or contained
in the frame are said to be the child controls.
Use the Caption property to set the frame's title.
• when you move the frame, all the child controls
also go with it. If you make the frame disabled or
invisible, all the child controls also become
disabled or invisible.
Shape control (shp)
• It can display six basic shapes: Rectangle,
Square, Oval, Circle, Rounded Rectangle, and
Rounded Square. It supports all the Line control's
properties and a few more: BorderStyle (0-
Transparent, 1-Solid), FillColor, and FillStyle (the
same as a form's properties with the same
names).
Shape cont’
• to draw a shape, just click on the shape control
and draw the shape on the form. The default
shape is a rectangle, with the default shape
property set at 0. You can change the shape to
square, oval, circle and rounded rectangle by
changing the shape property's value to 1, 2, 3 ,
4, and 5 respectively.
• Private Sub Form_Load()
• Shape1.Shape = 3
• End Sub
• Private Sub Form_Load()
• List1.AddItem "Rectangle"
• List1.AddItem "Square“
• List1.AddItem "Oval“
• List1.AddItem "Circle"
• List1.AddItem "Rounded Rectangle"
List1.AddItem "Rounded Square“
• End Sub
• Private Sub List1_Click()
• Select Case List1.ListIndex
• Case 0
• Shape1.Shape = 0
• Case 1
• Shape1.Shape = 1
• Case 2
• Shape1.Shape = 2
• Case 3
• Shape1.Shape = 3
• Case 4
• Shape1.Shape = 4
• Case 5
• Shape1.Shape = 5
• End Select
• End Sub
The Label
• Label1.caption=“jane”
The Command Button
• The command button is one of the most
important controls as it is used to execute
commands. It displays an illusion that the
button is pressed when the user click on it.
• The most common event associated with the
command button is the Click event, and the
syntax for the procedure is
• Private Sub Command1_Click ()
• Statements
• End Sub
A Simple Password Cracker
• Private Sub cmd_ShowPass_Click()
Dim yourpassword As String
yourpassword = Txt_Password.Text
MsgBox ("Your password is: " & yourpassword)
End Sub
The PictureBox