Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development...
Transcript of Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development...
![Page 1: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/1.jpg)
CBVP2103
![Page 2: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/2.jpg)
Evolved from BASIC
Beginner‟s All-Purpose Symbolic Instruction Code
Introduction to programming for novices
Introduced by Microsoft (1991)
Made programming for Windows much easier
• IDE facilitates quicker programming
Rapid Application Development
• Provided many extra features
Event handling
Graphical user interfaces
Object-oriented programming
![Page 3: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/3.jpg)
Motivated by popularity of electronic devices
Provide interaction between wide variety of devices◦ Web-based applications distributed to different
devices
Cell phones
Personal Digital Assistants
Personal computers
◦ Allow communication between programs of disparate languages
![Page 4: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/4.jpg)
Enhanced object orientation◦ Powerful library of components
Application development made even quicker
Enhanced language interoperability◦ Interaction between different languages
Old software compatible with Visual Basic .NET programs
Interaction over the Internet
Simple Object Access Protocol (SOAP)
Extensible Markup Language (XML)
Promotes use of Web services
![Page 5: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/5.jpg)
Introduced by Microsoft (June 2000)◦ Vision for embracing the Internet in software
development
Independence from specific language or platform◦ Applications developed in any .NET compatible language Visual Basic .NET, Visual C++ .NET, C# and more
◦ Programmers can contribute to applications using the language in which they are most competent
Architecture capable of existing on multiple platforms
New program development process◦ Provides increased productivity
Additional information available at Microsoft Web site www.microsoft.com/net
![Page 6: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/6.jpg)
Heart of .NET strategy◦ Manages and executes applications and Web services◦ Provides security, memory management and other
programming capabilities
Includes Framework class library (FCL)◦ Pre-packaged classes ready for reuse◦ Used by any .NET language
Details contained in Common Language Specification (CLS)◦ Submitted to European Computer Manufacturers
Association to make the framework easily converted to other platforms
Executes programs by Common Language Runtime (CLR)
![Page 7: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/7.jpg)
Base Class LibraryBase Class Library
Common Language SpecificationCommon Language Specification
Common Language RuntimeCommon Language Runtime
ADO.NET: Data and XMLADO.NET: Data and XML
VBVB C++C++ C#C#V
isu
al S
tud
io.N
ET
Vis
ual S
tud
io.N
ET
ASP.NET: Web ServicesASP.NET: Web Services
And Web FormsAnd Web Forms
JScriptJScript ……
WindowsWindows
formsforms
Cla
ss L
ibra
ries
Com
pliant
Languages
![Page 8: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/8.jpg)
Visual Studio .NET◦ Microsoft‟s Integrated Development Environment
(IDE)
◦ Used to create, run and debug programs (applications)
Visual programming◦ Dragging and dropping predefined building blocks
into place to create a simple Visual Basic program
![Page 9: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/9.jpg)
Start Page in Visual Studio .NET.
Location bar
![Page 10: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/10.jpg)
New Project dialog.
![Page 11: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/11.jpg)
Design WindowT
oolbox
SolutionExplorer
PropertiesWindow
![Page 12: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/12.jpg)
Menu Desc rip tion
File Contains commands for opening projects, closing projects, printing project data,
etc.
Edit Contains commands such as cut, paste, find, undo, etc.
View Contains commands for displaying IDE windows and toolbars.
Project Contains commands for managing a project and its files.
Build Contains commands for compiling a program.
Debug Contains commands for debugging (i.e., identifying and correcting problems in a
program) and running a program.
Data Contains commands for interacting with databases (i.e., files that store data,
which we discuss in Chapter 19, Databases, SQL and ADO .NET).
Format Contains commands for arranging a form’s controls.
Tools Contains commands for accessing additional IDE tools and options that enable
customization of the IDE.
Windows Contains commands for arranging and displaying windows.
Help Contains commands for accessing the IDE’s help features.
Fig. 2.5 Summary of Visua l Stud io .NET IDE menus.
Comma nd Desc rip tion
Contents Displays a categorized table of contents in which help articles are
organized by topic.
Index Displays an alphabetized list of topics through which the programmer
can browse.
Search Allows programmers to find help articles based on search keywords.
Fig. 2.13 Help menu c ommands.
![Page 13: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/13.jpg)
Simple program executing.
![Page 14: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/14.jpg)
Creating a new Windows Application.
![Page 15: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/15.jpg)
Setting the project location in the Project Location dialog.
![Page 16: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/16.jpg)
Fig. 2.18 Setting the form‟s Text property.
![Page 17: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/17.jpg)
Form with sizing handles.
![Page 18: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/18.jpg)
Changing the form‟s BackColor property.
![Page 19: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/19.jpg)
Adding a label to the form.
![Page 20: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/20.jpg)
Form elements are objects called controls
This form has:
◦ Two TextBox controls
◦ Four Label controls
◦ Two Button controls
The value displayed by a control is held in the text property of the control
Left button text property is Calculate Gross Pay
Buttons have methods attached to events
![Page 21: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/21.jpg)
Should be meaningful 1st 3 lowercase letters indicate the type of
control◦ txt… for Text Boxes◦ lbl… for Labels◦ btn… for Buttons
After that, capitalize the first letter of each word
txtHoursWorked is clearer than txthoursworked Change the name property
◦ Set the name of button1 to btnWelcome◦ Set the name of button2 to btnExit
![Page 22: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/22.jpg)
The GUI environment is event-driven
An event is an action that takes place within a program◦ Clicking a button (a Click event)
◦ Keying in a TextBox (a TextChanged event)
Visual Basic controls are capable of detecting many, many events
A program can respond to an event if the programmer writes an event procedure
![Page 23: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/23.jpg)
An Event Procedure is a block of code that executes only when particular event occurs
Writing an Event Procedure◦ Create the event procedure stub
Double click on control from Design Window – for default event for that control
OR
Open the Code Editor (F7 or View Menu/Code option)
Select Control & Select Event from drop down windows in Code Editor
◦ Add the event code to the event procedure stub
![Page 24: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/24.jpg)
![Page 25: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/25.jpg)
Select the btnWelcome control from the Form Controls List Box
![Page 26: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/26.jpg)
Select the Click event from the list of many available events
Buttons have 57 possible events they can respond to
![Page 27: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/27.jpg)
Beginning of Procedure is created for you◦ If you create stub by double clicking on control it
will create a stub for the most commonly used event for that control
![Page 28: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/28.jpg)
Write the code that you want executed when the user clicks on the btnWelcome button◦ Type: MsgBox (“Welcome to Visual Basic”)
◦ Must be contained within the Event Procedure Stub
![Page 29: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/29.jpg)
Not Case Sensitive◦ Visual Basic will “correct” case issues for you
Keywords are in Blue◦ Special reserved words
Comments in Green
Problems with Syntax (Language) will be underlined in blue
![Page 30: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/30.jpg)
Rules◦ Use spaces to separate the words and operators
◦ Indentation and capitalization have no effect
Recommendations◦ Use indentation and extra spaces for alignment
◦ Use blank lines before and after groups of related statements
◦ Code all variable declarations at the start of the procedure
◦ Group related declarations
![Page 31: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/31.jpg)
Usage◦ Type an apostrophe ( ' ) followed by the comment
◦ The compiler ignores everything on the line after „
◦ Used for documentation/readability and to disable chosen statements during testing
Recommendations◦ Follow apostrophe with a star for readability ( „* )
◦ Use at beginning of program to indicate author, purpose, date, etc.
◦ Use for groups of related statements and portions of code that are difficult to understand
![Page 32: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/32.jpg)
Public Class Form1
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventAr…
'*Variable declarationsDim dOrderTotal As DecimalDim dDiscountAmount As Decimal
'*Get total from textbox dOrderTotal = txtOrderTotal.Text
'*Calculate the proper discountdDiscountAmount = dOrderTotal * 0.25'dDiscountAmount = dOrderTotal * 0.25
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)…
'*Code goes here
End Sub
End Class
![Page 33: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/33.jpg)
Create an Event Procedure for when the btnExit button is clicked
Have it display “Goodbye” in a MsgBox
Then “End” – this will terminate the program
![Page 34: Visual Programming...2010/05/05 · Visual Studio .NET Microsoft‟s Integrated Development Environment (IDE) Used to create, run and debug programs (applications) Visual programming](https://reader035.fdocuments.in/reader035/viewer/2022081607/5ea5aa3a5764db52937b4cf1/html5/thumbnails/34.jpg)
Make sure to save your work◦ SAVE ALL (not Save Form)
◦ Visual Basic applications are
◦ made of several files -
◦ Often even several forms