SlideShare a Scribd company logo
1 of 33
VISUAL BASIC
STARTING A NEW PROJECT
THE PROPERTIES WINDOW
COMMON FORM PROPERTIES
SCALE PROPERTIES
COLOR PROPERTIES
THE TOOLBOX
CREATING CONTROL
THE NAME PROPERTY
PROPERTIES OF COMMAND BUTTONS
SIMPLE EVENT PROCEDURE FOR COMMAND BUTTONS
ACCESS KEY
IMAGE CONTROL
TEXTBOX,LABELS,MESSAGE BOX
GRID
VISUAL BASIC
Visual Basic is a event-driven programming Language from Microsoft known for
its Component Object Model (COM) programming.
Visual Basic was derived from BASIC and enables the rapid application development
(RAD) of graphical user interface (GUI) applications, access to databases using Data
Access Objects, Remote Data Objects or ActiveX Data Objects
A programmer can create an application using the components provided by the
Visual Basic program itself.
STARTING A NEW PROJECT
Create a project
There are multiple ways to create a new project in Visual Studio 2019. When
you first open Visual Studio, the start window appears, and from there, you can
choose Create a new project.
• Open Visual Studio 2019.
• On the start window, choose Create a new project.
If the Visual Studio development environment is already open, you can create a new
project by choosing File > New > Project on the menu bar or by clicking the New
Project button on the toolbar.
FROM THE TOOLS BOX, DRAG A PICTURE BOX ONTO YOUR FORM, DRAG A BUTTON ONTO YOUR
FORM AND DRAG AN OPEN FILE DIALOG ONTO YOUR FORM.
CONTROL PROPERTIES
To edit properties, click on the object and change the values in the properties window.
Form Properties
Text: Picture Viewer
Form Border Style: Fixed Tool Window
Picture Box
Background Image Layout: Zoom
Button
Text: Select Image
ADD CODE
VISUAL BASIC IDE(INTEGRADED DEVELOPMENT
ENVIRONMENT)
The Visual Studio integrated development environment is a creative that you
can use to edit, debug, and build code, and then publish an app.
An integrated development environment (IDE) is a feature-rich program that
can be used for many aspects of software development.
Over and above the standard editor and debugger that most IDEs provide,
Visual Studio includes compilers, code completion tools, graphical designers,
and many more features to ease the software development process.
• Solution Explorer (top right) lets you view, navigate, and manage your code
files. Solution Explorer can help organize your code by grouping the files
into solutions and projects.
• The editor window (center), where you'll likely spend a majority of your time,
displays file contents. This is where you can edit code or design a user
interface such as a window with buttons and text boxes.
• The Output window (bottom center) is where Visual Studio sends
notifications such as debugging and error messages, compiler warnings,
publishing status messages, and more. Each message source has its own tab.
• Explorer (bottom right) lets you track work and share code with others using
version control technologies.
THE PROPERTIES WINDOW
• The Properties window is used to display properties for objects selected in the two
main types of windows available in the Visual Studio integrated development
environment (IDE). These two types of windows are:
• Tool windows such as Solution Explorer, Class View, and Object browser
• Document windows containing such editors and designers as the forms designer,
XML editor, and HTML editor
Using the Properties Window
• The Properties window displays the properties of single or multiple selected items.
If multiple items are selected, the intersection of all properties for all selected
objects is displayed.
COMMON FORM PROPERTIES
• Name : It sets the name of the control, through which you can access the control’s properties and
methods.
• Appearance : It can be 0 for a flat look or 1 for a 3-D look.
• Back Color : It sets the background color on which text is displayed or graphics are drawn.
• Fore Color : It sets the foreground color
• Font : It sets the face, attribute, and size of the font used for the text on the control.
• Caption : It sets the text that is displayed on many controls that don’t accept input, for example, the
text on a Label control, the caption of a Command Button control.
• Text : It sets the text that is displayed on the controls that accept user input, for example, the TextBox
control.
• Width & Height : These properties set the control’s dimensions.
• Left & Top : These properties set the coordinates of the control’s upper-left corner, expressed in the
units of the container.
• Enabled : By default, this property’s value is True, which means that the control can get the focus.
• Visible : Set this property to False to make a control invisible.
SCALE PROPERTIES
• Width and Height Properties:The Width and Height properties of the Picture Box control are expressed in twips. If you change the
control’s coordinate system, the values of these two properties won’t change. If you resize the control on the Form by dragging
its handles with the mouse, the Width and Height properties will change value to reflect the new size of the control.
• Left “and Top Properties
• The Left and Top properties are the coordinates of the control’s upper-left comer, / and they are expressed in the container’s
coordinate system. If you change their values, the control is repositioned. They also change value if you change the
container’s coordinate system to reflect the control’s position in the new coordinate system.
• ScaleMode Property
• The ScnleMode property sets (or returns) the-control’s current coordinate system.
If you set this property to 0 (User), you must also set the ScaleWidth and ScaleHeight properties.
• ScaleWidth and ScaleHeight Properties
• These two properties are the control’s inner dimensions in units of the current coordinate system. Changing the coordinate system
doesn’tchange the size of the control, but it does change the number of units that can fit along the tW6 axes of the control.
• ScaleLeft and SealeTop Properties
• ScaleLeft and ScaleTop are the coordinates of the upper-left comer of the control in a user-defined system of
coordinates. Coordinate systems need not start at zero. Sca1eLeftis the minimum value an Xcoordinate can assume. The maximum
Xcoordinate is Sca1eLeft+ScaleWidth.
• Scale Method
• Using the Scale method is the most convenient way to set up a user-defined coordinate system.
The.coordinates 0; the upper-left comer of the control are (Xl, V, and (X2, Y2) are the coordinate of the lower-right comer.
COLOR PROPERTIES
properties of a control such as font, location, size, foreground color, background color,
MaximizeBox, MinimizeBox and etc. You can also change the properties of the object
at runtime to give special effects such as change of color, shape, animation effect and
so on
• Forecolor
• Backcolor
• Backgroundimage
• Backgroundcolor
THE TOOLBOX
• The Toolbox contains a set of controls that are used to place on a Form at design
time thereby creating the user interface area. Additional controls can be included in
the toolbox by using the Components menu item on the Project menu.
Control Description
Pointer Provides a way to move and resize the controls form
PictureBox Displays icons/bitmaps and metafiles. It displays text or acts as a visual container for other controls.
TextBox Used to display message and enter text.
Frame Serves as a visual and functional container for controls
CommandButton Used to carry out the specified action when the user chooses it.
CheckBox Displays a True/False or Yes/No option.
OptionButton OptionButton control which is a part of an option group allows the user to select only one option even it displays mulitiple choices.
ListBox Displays a list of items from which a user can select one.
ComboBox Contains a TextBox and a ListBox. This allows the user to select an ietm from the dropdown ListBox, or to type in a selection in the TextBox.
HScrollBar and VScrollBar These controls allow the user to select a value within the specified range of values
Timer Executes the timer events at specified intervals of time
DriveListBox Displays the valid disk drives and allows the user to select one of them.
DirListBox Allows the user to select the directories and paths, which are displayed.
FileListBox Displays a set of files from which a user can select the desired one.
Shape Used to add shape (rectangle, square or circle) to a Form
Line Used to draw straight line to the Form
Image used to display images such as icons, bitmaps and metafiles. But less capability than the PictureBox
Data Enables the use to connect to an existing database and display information from it.
OLE Used to link or embed an object, display and manipulate data from other windows based applications.
Label Displays a text that the user cannot modify or interact with.
CREATING CONTROL AND THE NAME
PROPERTY
• Every control has it’s properties one of the common properties of controls is name
property. Name property is the one by which the control is identified and it is
referred as the object name of that control.
• By using name property programmer can access the other properties of the controls
and methods as well at run time.
•
• Visual Basic gives default name to the controls which can be later changed by
changing it’s name property at the design time or urn time.
PROPERTIES OF COMMAND BUTTON
• The main function of the CommandButton control is to run code when the user
clicks on it. You should keep the following points in mind when programming with
CommandButton properties:
• You should always change the Caption property of a CommandButton. The Caption
property contains the text displayed on the CommandButton. This property can be
changed at design time and runtime.
• The Cancel property is a Boolean type. It allows VB to associate the Escape key with
the CommandButton's Click event procedure. Thus if you set Cancel to True, the
Click event procedure fires when the user presses the Escape key. Cancel buttons are
usually associated the with the Escape key.
COMMON PROPERTIES OF COMMAND BUTTON
Property Description
Left The position of the left side of a control with
respect to its container
Top The position of the top of a control with respect to
its container
Height A control's height
Width A control's width
Name The string value used to refer to a control
Enabled The Boolean (True/False) value that determines
whether users can manipulate the control
Visible The Boolean (True/False) value that determines
whether users can see the control
COMMON METHODS OF VISUAL BASIC
CONTROLS
Method Use
Move Changes an object's position in response to a code
request
Drag Handles the execution of a drag-and-drop
operation by the user
SetFocus Gives focus to the object specified in the method
call
ZOrder Determines the order in which multiple objects
appear onscreen
COMMON EVENTS OF VISUAL BASIC
CONTROLS
Event Occurrence
Change The user modifies text in a combo box or text box.
Click The user clicks the primary mouse button on an object.
DblClick The user double-clicks the primary mouse button on an object.
DragDrop The user drags an object to another location.
DragOver The user drags an object over another control.
GotFocus An object receives focus.
KeyDown The user presses a keyboard key while an object has focus.
KeyPress The user presses and releases a keyboard key while an object has focus.
KeyUp The user releases a keyboard key while an object has focus.
Event Occurrence
LostFocus An object loses focus.
MouseDown The user presses any mouse button while the mouse pointer is over an
object.
MouseMove The user moves the mouse pointer over an object.
MouseUp The user releases any mouse button while the mouse pointer is over an
object.
SIMPLE EVENT PROCEDURE FOR
COMMAND BUTTONS
• A procedure contains a series of Visual Basic statements that perform an operation
or calculate a value. An event procedure is a procedure that runs in response to an
event.
To write the event procedure for the OK command button
• 1 In Design view, right-click the object (form, report, section, or control) for which
you want to write an event procedure, in this case, the OK command button. On the
shortcut menu, click Build Event.
• Microsoft Access displays the Choose Builder dialog box.
• 2 In the list box, click Code Builder, and then click OK.
ACCESS KEY
• An access key is an underlined character in the text of a menu, menu item, or the
label of a control such as a button. With an access key, the user can "click" a button
by pressing the Alt key in combination with the predefined access key.
• For example, if a button runs a procedure to print a form, and therefore its property
is set to "Print," adding an ampersand before the letter "P" causes the letter "P" to
be underlined in the button text at run time. The user can run the command
associated with the button by pressing Alt+P.
IMAGE CONTROL
• The PictureBox control is used for displaying images on the form. The Image property of
the control allows you to set an image both at design time or at run time. Let's create a picture box
by dragging a PictureBox control from the Toolbox and dropping it on the form.
• Image
Gets or sets the image that is displayed in the control.
ImageLocation
• Gets or sets the path or the URL for the image displayed in the control.
InitialImage
• Gets or sets the image displayed in the control when the main image is loaded.
SizeMode
• Determines the size of the image to be displayed in the control. This property takes its value from the
PictureBoxSizeMode enumeration, which has values −
• Normal − the upper left corner of the image is placed at upper left part of the picture box
• StrechImage − allows stretching of the image
• AutoSize − allows resizing the picture box to the size of the image
• CenterImage − allows centering the image in the picture box
• Zoom − allows increasing or decreasing the image size to maintain the size ratio.
TEXTBOX,LABELS,MESSAGE BOX
• The Label
• The label can be used to provide instructions and guides to the users as well as to display
outputs. It is different from text box because it can only display static text, which means the user
cannot change the text.
• TextBox
• The TextBox control is for accepting input from the user as well as to display the output. It can
handle string and numeric data but not images or pictures. String in a text box can be converted
to a numeric data by using the function Val(text). The label control is only for displaying a
caption/title or to display an output.
• A message box is a special dialog box used to display a piece of information to the user. As
opposed to a regular form, the user cannot type anything in the dialog box. To support message
boxes, the Visual Basic language provides a function named MsgBox.
• To display a simple message box, you can use the MsgBox() function with the following formula:
GRID
• A grid view or a datagrid is a graphical control element that presents a tabular
view of data.
• Clicking a column header to change the sort order of the grid
• Dragging column headers to change their size and their order
• In-place editing of viewed data
• Row and column separators, and alternating row background colors
Visual Basic.pptx

More Related Content

Similar to Visual Basic.pptx

Similar to Visual Basic.pptx (20)

Visual Basic Controls ppt
Visual Basic Controls pptVisual Basic Controls ppt
Visual Basic Controls ppt
 
Visual basic
Visual basicVisual basic
Visual basic
 
Vb basics
Vb basicsVb basics
Vb basics
 
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
 
Grasping The LightSwitch Paradigm
Grasping The LightSwitch ParadigmGrasping The LightSwitch Paradigm
Grasping The LightSwitch Paradigm
 
Introduction to Visual Basic (Week 2)
Introduction to Visual Basic (Week 2)Introduction to Visual Basic (Week 2)
Introduction to Visual Basic (Week 2)
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptx
 
VB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdfVB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdf
 
VB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdfVB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdf
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Visual basic concepts
Visual basic conceptsVisual basic concepts
Visual basic concepts
 
What’s new in XAML and Tooling for Windows 8.1
What’s new in XAML and Tooling for Windows 8.1What’s new in XAML and Tooling for Windows 8.1
What’s new in XAML and Tooling for Windows 8.1
 
Introduction to Visual Basic 6.0
Introduction to Visual Basic 6.0Introduction to Visual Basic 6.0
Introduction to Visual Basic 6.0
 
Tugas testing
Tugas testingTugas testing
Tugas testing
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic
 
Visual basic
Visual basic Visual basic
Visual basic
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
Exploring Adobe Flex
Exploring Adobe Flex Exploring Adobe Flex
Exploring Adobe Flex
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 

Visual Basic.pptx

  • 1.
  • 2. VISUAL BASIC STARTING A NEW PROJECT THE PROPERTIES WINDOW COMMON FORM PROPERTIES SCALE PROPERTIES COLOR PROPERTIES THE TOOLBOX CREATING CONTROL THE NAME PROPERTY PROPERTIES OF COMMAND BUTTONS SIMPLE EVENT PROCEDURE FOR COMMAND BUTTONS ACCESS KEY IMAGE CONTROL TEXTBOX,LABELS,MESSAGE BOX GRID
  • 3. VISUAL BASIC Visual Basic is a event-driven programming Language from Microsoft known for its Component Object Model (COM) programming. Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using Data Access Objects, Remote Data Objects or ActiveX Data Objects A programmer can create an application using the components provided by the Visual Basic program itself.
  • 4. STARTING A NEW PROJECT Create a project There are multiple ways to create a new project in Visual Studio 2019. When you first open Visual Studio, the start window appears, and from there, you can choose Create a new project. • Open Visual Studio 2019. • On the start window, choose Create a new project. If the Visual Studio development environment is already open, you can create a new project by choosing File > New > Project on the menu bar or by clicking the New Project button on the toolbar.
  • 5.
  • 6. FROM THE TOOLS BOX, DRAG A PICTURE BOX ONTO YOUR FORM, DRAG A BUTTON ONTO YOUR FORM AND DRAG AN OPEN FILE DIALOG ONTO YOUR FORM.
  • 8. To edit properties, click on the object and change the values in the properties window. Form Properties Text: Picture Viewer Form Border Style: Fixed Tool Window Picture Box Background Image Layout: Zoom Button Text: Select Image
  • 10. VISUAL BASIC IDE(INTEGRADED DEVELOPMENT ENVIRONMENT) The Visual Studio integrated development environment is a creative that you can use to edit, debug, and build code, and then publish an app. An integrated development environment (IDE) is a feature-rich program that can be used for many aspects of software development. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to ease the software development process.
  • 11.
  • 12. • Solution Explorer (top right) lets you view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects. • The editor window (center), where you'll likely spend a majority of your time, displays file contents. This is where you can edit code or design a user interface such as a window with buttons and text boxes. • The Output window (bottom center) is where Visual Studio sends notifications such as debugging and error messages, compiler warnings, publishing status messages, and more. Each message source has its own tab. • Explorer (bottom right) lets you track work and share code with others using version control technologies.
  • 13. THE PROPERTIES WINDOW • The Properties window is used to display properties for objects selected in the two main types of windows available in the Visual Studio integrated development environment (IDE). These two types of windows are: • Tool windows such as Solution Explorer, Class View, and Object browser • Document windows containing such editors and designers as the forms designer, XML editor, and HTML editor Using the Properties Window • The Properties window displays the properties of single or multiple selected items. If multiple items are selected, the intersection of all properties for all selected objects is displayed.
  • 14. COMMON FORM PROPERTIES • Name : It sets the name of the control, through which you can access the control’s properties and methods. • Appearance : It can be 0 for a flat look or 1 for a 3-D look. • Back Color : It sets the background color on which text is displayed or graphics are drawn. • Fore Color : It sets the foreground color • Font : It sets the face, attribute, and size of the font used for the text on the control. • Caption : It sets the text that is displayed on many controls that don’t accept input, for example, the text on a Label control, the caption of a Command Button control. • Text : It sets the text that is displayed on the controls that accept user input, for example, the TextBox control. • Width & Height : These properties set the control’s dimensions. • Left & Top : These properties set the coordinates of the control’s upper-left corner, expressed in the units of the container. • Enabled : By default, this property’s value is True, which means that the control can get the focus. • Visible : Set this property to False to make a control invisible.
  • 15. SCALE PROPERTIES • Width and Height Properties:The Width and Height properties of the Picture Box control are expressed in twips. If you change the control’s coordinate system, the values of these two properties won’t change. If you resize the control on the Form by dragging its handles with the mouse, the Width and Height properties will change value to reflect the new size of the control. • Left “and Top Properties • The Left and Top properties are the coordinates of the control’s upper-left comer, / and they are expressed in the container’s coordinate system. If you change their values, the control is repositioned. They also change value if you change the container’s coordinate system to reflect the control’s position in the new coordinate system. • ScaleMode Property • The ScnleMode property sets (or returns) the-control’s current coordinate system. If you set this property to 0 (User), you must also set the ScaleWidth and ScaleHeight properties. • ScaleWidth and ScaleHeight Properties • These two properties are the control’s inner dimensions in units of the current coordinate system. Changing the coordinate system doesn’tchange the size of the control, but it does change the number of units that can fit along the tW6 axes of the control. • ScaleLeft and SealeTop Properties • ScaleLeft and ScaleTop are the coordinates of the upper-left comer of the control in a user-defined system of coordinates. Coordinate systems need not start at zero. Sca1eLeftis the minimum value an Xcoordinate can assume. The maximum Xcoordinate is Sca1eLeft+ScaleWidth. • Scale Method • Using the Scale method is the most convenient way to set up a user-defined coordinate system. The.coordinates 0; the upper-left comer of the control are (Xl, V, and (X2, Y2) are the coordinate of the lower-right comer.
  • 16. COLOR PROPERTIES properties of a control such as font, location, size, foreground color, background color, MaximizeBox, MinimizeBox and etc. You can also change the properties of the object at runtime to give special effects such as change of color, shape, animation effect and so on • Forecolor • Backcolor • Backgroundimage • Backgroundcolor
  • 17.
  • 18. THE TOOLBOX • The Toolbox contains a set of controls that are used to place on a Form at design time thereby creating the user interface area. Additional controls can be included in the toolbox by using the Components menu item on the Project menu. Control Description Pointer Provides a way to move and resize the controls form PictureBox Displays icons/bitmaps and metafiles. It displays text or acts as a visual container for other controls. TextBox Used to display message and enter text. Frame Serves as a visual and functional container for controls CommandButton Used to carry out the specified action when the user chooses it. CheckBox Displays a True/False or Yes/No option. OptionButton OptionButton control which is a part of an option group allows the user to select only one option even it displays mulitiple choices. ListBox Displays a list of items from which a user can select one. ComboBox Contains a TextBox and a ListBox. This allows the user to select an ietm from the dropdown ListBox, or to type in a selection in the TextBox. HScrollBar and VScrollBar These controls allow the user to select a value within the specified range of values Timer Executes the timer events at specified intervals of time DriveListBox Displays the valid disk drives and allows the user to select one of them. DirListBox Allows the user to select the directories and paths, which are displayed. FileListBox Displays a set of files from which a user can select the desired one. Shape Used to add shape (rectangle, square or circle) to a Form Line Used to draw straight line to the Form Image used to display images such as icons, bitmaps and metafiles. But less capability than the PictureBox Data Enables the use to connect to an existing database and display information from it. OLE Used to link or embed an object, display and manipulate data from other windows based applications. Label Displays a text that the user cannot modify or interact with.
  • 19.
  • 20. CREATING CONTROL AND THE NAME PROPERTY • Every control has it’s properties one of the common properties of controls is name property. Name property is the one by which the control is identified and it is referred as the object name of that control. • By using name property programmer can access the other properties of the controls and methods as well at run time. • • Visual Basic gives default name to the controls which can be later changed by changing it’s name property at the design time or urn time.
  • 21. PROPERTIES OF COMMAND BUTTON • The main function of the CommandButton control is to run code when the user clicks on it. You should keep the following points in mind when programming with CommandButton properties: • You should always change the Caption property of a CommandButton. The Caption property contains the text displayed on the CommandButton. This property can be changed at design time and runtime. • The Cancel property is a Boolean type. It allows VB to associate the Escape key with the CommandButton's Click event procedure. Thus if you set Cancel to True, the Click event procedure fires when the user presses the Escape key. Cancel buttons are usually associated the with the Escape key.
  • 22. COMMON PROPERTIES OF COMMAND BUTTON Property Description Left The position of the left side of a control with respect to its container Top The position of the top of a control with respect to its container Height A control's height Width A control's width Name The string value used to refer to a control Enabled The Boolean (True/False) value that determines whether users can manipulate the control Visible The Boolean (True/False) value that determines whether users can see the control
  • 23. COMMON METHODS OF VISUAL BASIC CONTROLS Method Use Move Changes an object's position in response to a code request Drag Handles the execution of a drag-and-drop operation by the user SetFocus Gives focus to the object specified in the method call ZOrder Determines the order in which multiple objects appear onscreen
  • 24. COMMON EVENTS OF VISUAL BASIC CONTROLS Event Occurrence Change The user modifies text in a combo box or text box. Click The user clicks the primary mouse button on an object. DblClick The user double-clicks the primary mouse button on an object. DragDrop The user drags an object to another location. DragOver The user drags an object over another control. GotFocus An object receives focus. KeyDown The user presses a keyboard key while an object has focus. KeyPress The user presses and releases a keyboard key while an object has focus. KeyUp The user releases a keyboard key while an object has focus. Event Occurrence LostFocus An object loses focus. MouseDown The user presses any mouse button while the mouse pointer is over an object. MouseMove The user moves the mouse pointer over an object. MouseUp The user releases any mouse button while the mouse pointer is over an object.
  • 25. SIMPLE EVENT PROCEDURE FOR COMMAND BUTTONS • A procedure contains a series of Visual Basic statements that perform an operation or calculate a value. An event procedure is a procedure that runs in response to an event. To write the event procedure for the OK command button • 1 In Design view, right-click the object (form, report, section, or control) for which you want to write an event procedure, in this case, the OK command button. On the shortcut menu, click Build Event. • Microsoft Access displays the Choose Builder dialog box. • 2 In the list box, click Code Builder, and then click OK.
  • 26.
  • 27.
  • 28. ACCESS KEY • An access key is an underlined character in the text of a menu, menu item, or the label of a control such as a button. With an access key, the user can "click" a button by pressing the Alt key in combination with the predefined access key. • For example, if a button runs a procedure to print a form, and therefore its property is set to "Print," adding an ampersand before the letter "P" causes the letter "P" to be underlined in the button text at run time. The user can run the command associated with the button by pressing Alt+P.
  • 29. IMAGE CONTROL • The PictureBox control is used for displaying images on the form. The Image property of the control allows you to set an image both at design time or at run time. Let's create a picture box by dragging a PictureBox control from the Toolbox and dropping it on the form. • Image Gets or sets the image that is displayed in the control. ImageLocation • Gets or sets the path or the URL for the image displayed in the control. InitialImage • Gets or sets the image displayed in the control when the main image is loaded. SizeMode • Determines the size of the image to be displayed in the control. This property takes its value from the PictureBoxSizeMode enumeration, which has values − • Normal − the upper left corner of the image is placed at upper left part of the picture box • StrechImage − allows stretching of the image • AutoSize − allows resizing the picture box to the size of the image • CenterImage − allows centering the image in the picture box • Zoom − allows increasing or decreasing the image size to maintain the size ratio.
  • 30. TEXTBOX,LABELS,MESSAGE BOX • The Label • The label can be used to provide instructions and guides to the users as well as to display outputs. It is different from text box because it can only display static text, which means the user cannot change the text. • TextBox • The TextBox control is for accepting input from the user as well as to display the output. It can handle string and numeric data but not images or pictures. String in a text box can be converted to a numeric data by using the function Val(text). The label control is only for displaying a caption/title or to display an output. • A message box is a special dialog box used to display a piece of information to the user. As opposed to a regular form, the user cannot type anything in the dialog box. To support message boxes, the Visual Basic language provides a function named MsgBox. • To display a simple message box, you can use the MsgBox() function with the following formula:
  • 31.
  • 32. GRID • A grid view or a datagrid is a graphical control element that presents a tabular view of data. • Clicking a column header to change the sort order of the grid • Dragging column headers to change their size and their order • In-place editing of viewed data • Row and column separators, and alternating row background colors