Vous êtes sur la page 1sur 24

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name of the faculty : G. Radha
Designation : Lecturer
Branch : CCP
Institute : 026 - SG Govt. Polytechnic,
Adilabad
Year / Semester : III Year / V Semester
Subject : Visual Basic – I
Subject Code : CCP - 503
Topic : Understand Menus and
Common dialogue control .
Duration : 50 Mts.
Sub Topic : Custom dialogue boxes.
Teaching Aids : Animations & Images

CCP-503.19 1
Recap

 Predefined Dialogue Boxes.

CCP-503.19 2
Objectives :

Upon the completion of this period ,you will


be able to understand about
 Custom Dialogue Boxes.

CCP-503.19 3
Custom Dialogue Boxes
 Custom Dialogue Box is a Form that is created
by the user containing controls including
Command button, Option button and Text Box
Controls
 Custom Dialogue Boxes are customized by the
user

 The appearance of the Form is customized by


setting the property value

NOTE : The code part of dialogue boxes may be


explained after lessons on programming

CCP-503.19 4
Design a Custom Dialogue Box

 The Dialog.vbp project is opened and a new Form


is added to the project by selecting the add Form
from the Project Menu.

 The Form of the project is saved as Custom.frm.

 The Custom Form is designed as per the following


specifications.

CCP-503.19 5
Design a Custom Dialogue Box

Object Property Settings

Form Caption CUSTOM


DIALOG
APPLICATION
Name Custom
Max Button False
Min Button False
Control Box False
Border Style 1- Fixed Single
Option Button Caption Monday
Name Option1
CCP-503.19 6
Design a Custom Dialogue Box

Object Property Settings

Option Button Caption Tuesday

Name Option2
Option Button Caption Wednesday
Name Option3
Option Button Caption Thursday
Name Option4
Option Button Caption Friday
Name Option5

CCP-503.19 7
Design a Custom Dialogue Box

Object Property Settings


Option Button Caption Saturday
Name Option6
Option Button Caption Sunday
Name Option7
Command Button Caption &OK
Name Command1
Command Button Caption E&xit
Name Command2

CCP-503.19 8
Design a Custom Dialogue Box
 Two Menu Items are added to the Dialog.frm Form
of the Dialog.vbp project with the following
characteristics.

 These Menu Items are inserted above the Exit Menu


Item.

Caption Name

….Get a Da&y MnDay

….- MnSep3

CCP-503.19 9
After adding the Menu Items, Dialog Form
looks like

CCP-503.19 10
Design a Custom Dialogue Box
 The following code is entered in the
MnDay_Click() procedure of Dialog Form.

Private Sub MnDay_Click()


Custom.Show 1
If Custom.Tag = " " Then
MsgBox "Dialogue Box is Cancelled"
Else
MsgBox "The selected day is : " +
Custom.Tag
End If
End Sub

CCP-503.19 11
Design a Custom Dialogue Box

 When the Menu Item Get a Day is clicked, it displays


the Custom.frm as a Custom dialogue box and
prompts the user to select a day.

 It also displays the day which is selected by using


the Tag property of the Custom Form Dialog
dialogue box.

 The code used Custom.Tag to store the name of the


day which is selected.

CCP-503.19 12
Design a Custom Dialogue Box

CCP-503.19 13
Design a Custom Dialogue Box
 The following code is entered in the
Command1_Click() procedure of Custom Form.
Private Sub Command1_Click()
If Option1 = True Then Custom.Tag = "Monday"
If Option2 = True Then Custom.Tag = "Tuesday"
If Option3 = True Then Custom.Tag = "Wednesday"
If Option4 = True Then Custom.Tag = "Thursday"
If Option5 = True Then Custom.Tag = "Friday"
If Option6 = True Then Custom.Tag = "Saturday"
If Option7 = True Then Custom.Tag = "Sunday, So
No Transaction"
Custom.Hide
End Sub
CCP-503.19 14
Design a Custom Dialogue Box

 Whenever the OK button of the Custom Form


dialogue box is clicked, the code written in the
procedure of Command1_Click() is executed.

 The If statements are used here to ascertain the


Option button that is currently selected and
accordingly updates the Tag property of the Custom
Form dialogue box with the name of selected day.

 After the If statements, the procedure uses Hide


method to hide the Custom Form dialogue box.

CCP-503.19 15
Design a Custom Dialogue Box

 The Tag property of the dialogue box is used as the


output of the dialogue box.

 When the user selects the Option button Sunday, a


message box is displayed.

CCP-503.19 16
Design a Custom Dialogue Box

 When the user selects the Option button


other than Sunday, a message box is
displayed.

CCP-503.19 17
Design a Custom Dialogue Box

 The following code is entered in the


Command2_Click() procedure of Custom Form
dialogue box.

Private Sub Command2_Click()


Custom.Tag = " "
Custom.Hide
End
End Sub

CCP-503.19 18
Design a Custom Dialogue Box

 Whenever the Exit button is clicked the Tag property


of the Custom Form dialogue box is set to null and
the Hide method hides the Form.

 Setting the Custom Form Tag to null indicates that


the user clicked the Exit button.

CCP-503.19 19
Summary
 Custom Dialogue Control.

CCP-503.19 20
Quiz

CCP-503.19 21
1. A Form can be used as a _______
dialogue box.

A) Predefined
B) Custom
C) Common
D) System Default

CCP-503.19 22
Frequently Asked Questions

1. Explain in detail about Custom Dialogue


Control.

CCP-503.19 23
Assignment
1. Prepare an application with a dialogue
box that asks a month name and shows
a number of days in the month.

CCP-503.19 24

Vous aimerez peut-être aussi