Download presentation
Presentation is loading. Please wait.
1
Slide 1 VB Default Controls Text Box, Check Box, Option Button & Frames
2
Slide 2 Default Controls
3
Slide 3 Control Function
4
Slide 4 Control Function
5
Slide 5 Other Controls v The controls shown are not the only ones included with VB. To add other controls such as the Microsoft CommonDialog control or Microsoft FlexGrid control : –use the Components dialog box by choosing Project, Components, or right-clicking an empty area of the Toolbox and selecting Components from the context menu.
6
Slide 6 Text Box v The AutoSize Property v The WordWrap Property v New Line: (vbCrLf) –Label1.caption = “First Line” & vbCrLf & “Second Line”
7
Slide 7 Text Box v Handling Multiple Lines of Text by MultiLine and ScrollBar properties.
8
Slide 8 Controls for Making Choices v Check Box: Switches one or more options on or off v Option Button: Selects a single choice from a group v List Box: Displays a list of user-defined items v Combo Box: Like a list box, but also displays selected item
9
Slide 9 Check Boxes If chkBan = 1 Then lblChoice.Caption = "Bannana“ End If If chkTom = 1 Then lblChoice.Caption = "Tomato" End If
10
Slide 10 Check Boxes v Style Property –0 – Standard, 1 – Graphical v Picture Property –set the picture when not checked v DownPicture –set picture when checked v DisabledPicture –set picture when disabled or grayed
11
Slide 11 Option Buttons v also called radio buttons, v they exist in a group, only one of them can be “selected” at a time. v To use them: –Draw a group of option buttons –You can give each of them a different name –OR you can give them the same name (VB will ask u if you want to create a control array: answer “Yes”)
12
Slide 12 Option Buttons v It can be used in programming in two ways: –1. Use the Click event if you want to take an action when users select an option. (Control Array) – Happens Immediately Private Sub optWash_Click(Index As Integer) Select Case Index Case 0 MsgBox “You selected: Normal” Case 1 MsgBox “You selected: Heavy Duty” Case 2 MsgBox “You selected: Pots and Pans” End Select End Sub
13
Slide 13 Option Buttons –2. use an if statement to check their state (no control array) – Do not Happen Immediately : Private Sub cmdStartWash_Click() If optNormal = True Then MsgBox “You selected: Normal” Elseif optHeavy = True Then MsgBox “You selected: Heavy Duty” Else MsgBox “You selected: Pots and Pans” End If End Sub
14
Slide 14 Option Buttons v To have multiple option buttons on a form selected at the same time: separate the option buttons into groups by using container controls (frame).
15
Slide 15 Frames v A type of control called a container. v Containers are controls in which you can draw other controls. v After you draw a Frame control, you are ready to start placing other controls in it. You can place any controls you like in the frame (or any other container). You can even place containers within containers. v The only way to move a control from other parts of the form into the frame is to cut and paste
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.