VB .Net Programming
Unit-I:
1. Introduction to .NET.
2. NET Framework features & architecture.
CLR, Common Type System, MSIL, Assemblies and class libraries.
3. Introduction to Visual studio.
Project basics, types of project in. Net,
4. IDE of VB.NET- Menu bar, Toolbar, Solution Explorer, Toolbox, Properties Window, Form Designer, Output Window, Object Browser
4. The environment:
Editor tab, Format tab, General tab, docking tab.
5. Visual development & event driven.
6. Programming -Methods and events.
1. Introduction to .NET
Visual Basic .NET (VB.NET) is an object-oriented computer programming language implemented on the .NET Framework. VB.NET has complete support for object-oriented concepts. Everything in VB.NET is an object, including all of the primitive types (Short, Integer, Long, String, Boolean, etc.) and user-defined types, events, and even assemblies. All objects inherits from the base class Object.
The VB.NET stands for Visual Basic. Network Enabled Technologies. It is a simple, high-level, object oriented programming language developed by Microsoft in 2002. It is a successor of Visual Basic 6.0, that is implemented on the Microsoft .NET framework.
Applications built using the VB.NET language are very reliable and scalable, relying on the .NET Framework to access all libraries that help to execute a VB.NET program. With this language, you can develop a fully object-oriented application that is similar to an application created throughanother language such as C++, Java, or C#.
2. NET Framework features & architecture.
o It is an object-oriented programming language that follows various oops concepts such as abstraction, encapsulation, inheritance, and many more. It means that everything in VB.NET programming will be treated as an object.
o This language is used to design user interfaces for window, mobile, and web based applications.
o It is not a case sensitive language like other languages such as C++, java, etc. o It supports Boolean condition for decision making in programming. o It also supports the multithreading concept, in which you can do multiple tasks at the same time.
o It provides simple events management in .NET application.
o It is useful to develop web, window, and mobile applications.
2.1. Architecture.
Components of .NET Framework
There are following components of .NET Framework:
1. CLR (Common Language Runtime)
2. CTS (Common Type System)
3. MSIL (Microsoft Intermediate Language)
4. Class Library and .NET Assemblies
CLR (common language runtime)
It is an important part of a .NET framework that works like a virtual component of the .NET Framework to executes the different languages program like c#, Visual Basic, etc. A CLR also helps to convert a source code into the byte code, and this byte code is known as CIL (Common Intermediate Language) or MSIL (Microsoft Intermediate Language). After converting into a byte code, a CLR uses a JIT compiler at run time that helps to convert a CIL or MSIL code into the machine or native code.
CTS (Common Type System)
It specifies a standard that represent what type of data and value can be defined and managed in computer memory at runtime. A CTS ensures that programming data defined in various languages should beinteract with each other to share information. For example, in C# we define data type as int, while in VB.NET we define integer as a data type.
MSIL (Microsoft Intermediate Language)
The Microsoft Intermediate Language (MSIL), also known as the Common Intermediate Language (CIL) is a set of instructions that are platform independent and are generated by the language-specific compiler from the source code. The MSIL is platform independent and consequently, it can be executed on any of the Common Language Infrastructure supported environments such as the Windows .NET runtime. The MSIL is converted into a particular computer environment specific machine code by the JIT compiler. This is done before the MSIL can be executed. Also, the MSIL is converted into the machine code on a requirement basis i.e. the JIT compiler compiles the MSIL as required rather than the whole of it.
Microsoft .NET Assemblies
A .NET assembly is the main building block of the .NET Framework. It is a small unit of code that contains a logical compiled code in the Common Language infrastructure (CLI), which is used for deployment, security and versioning. It defines in two parts (process) DLL and library (exe) assemblies. When the .NET program is compiled, it generates a metadata with Microsoft Intermediate Language, which is stored in a file called Assembly.
FCL (Framework Class Library)
It provides the various system functionality in the .NET Framework that includes classes, interfaces and data types, etc. to create multiple functions and different types of application such as desktop, web, mobile application, etc. In other words, it can be defined as, it provides a base on which various applications, controls and components are built in .NET Framework.
Key Components of FCL
1. Object type
2. Implementation of data structure
3. Base data types
4. Garbage collection
5. Security and database connectivity
6. Creating common platform for window and web-based application. Versions of VB.Net
1. On 13 February 2002, Microsoft launched first version of .Net framework 1.0. 2. The second version 2.0 of .net framework was launched on 22 January 2006. 3. Third version 3.0 of .Net framework was released on 21 November 2006. 4. A .Net framework version 3.5 was released on 19 November 2007. 5. Version 4.0 of .Net framework was released on 29 September 2008 6. Version 4.5 of .Net framework was released on 15 August 2012. 7. .Net framework 4.5.1 version was announced on 17 October 2013
8. On 5 May 2014, a 4.5.2 version of .Net framework was released. 9. .Net framework 4.6 version was announced on 12 November 2014 10. .Net framework 4.6.1 version was released on 30 October 2015
11. .Net framework 4.6.2 version was announced on March 30, 2016 12. .Net framework 4.7 version was announced on April 5, 2017
13. .Net framework 4.7.1 version was announced on October 17, 2017 14. Version 4.7.2 of .Net framework was released on 30 April 2018.
15. And currently we are using .Net framework version 4.8 that was released on 18 April 2019
3. Introduction to Visual studio
The Visual Studio integrated development environment is a creative launching pad 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.
A] Types of project in. Net
∙ Windows Application—this is a standard executable, in VB6 terminology. It is the way to create applications with a Windows interface, using forms and controls. This is as close to "your father's VB" as you'll get in VB.NET.
∙ Class Library—this project type allows you to create classes that will be used in other applications. Think of it as similar to the COM components that you have been building, which VB6 called the ActiveX DLL and ActiveX EXE project types.
∙ Windows Control Library—this project type is for creating what used to be called ActiveX controls. This type allows you to create new controls to be used in Windows applications.
∙ Web Application—Goodbye, Visual InterDev. Goodbye, scripting languages on the server. Visual Basic now has Web Application projects, which use ASP.NET to create dynamic Web applications. These projects allow you to create HTML, ASP.NET, and VB files. Your Web applications move beyond the simple request/response mode of typical Web applications to be event-driven.
∙ Web Service— Web Service projects are components that you make available to other applications via the Web; the underlying protocol is HTTP instead of DCOM, and you are passing requests and receiving responses behind the scenes using XML. Some of the major promises of Web Service projects are that they are all standards-based and are platform-independent. Unlike DCOM, which was tied to a COM (that is, Windows) infrastructure, Web Service projects can be placed on any platform that supports .NET, and can then be called by any application using simple HTTP calls.
∙ Web Control Library—As with Web Service projects, there's no exact match back to VB6 for the Web Control Library projects. Thanks to the new Web Application projects in VB.NET, you can add controls to Web pages just like you would in a standard Windows Application, but VB.NET makes them HTML controls at runtime. You can design your own controls that can then be used by Web applications.
∙ Console Application—Many of the Windows administrative tools are still console (or command-line, or DOS) applications. Previously, you didn't have a good way to create these tools in VB, and you instead had to rely on C++. Now console applications are natively supported by VB.NET.
∙ Windows Services—As with console applications, there was no good way to create Windows services in previous versions of VB. Windows services, of course, are programs that run in the background of Windows and can automatically start when the machine is booted, even if no one logs in.
Menu Bar
This Menu Bar displays the commands that are required to build an application. The main menu items have sub menu items that can be chosen when needed. The toolbars in the
menu bar provide quick access to the commonly used commands and a button in the toolbar is clicked once to carry out the action represented by it.
Toolbars
Visual Basic Toolbar
Standard Toolbar
Edit Toolbar
Debug Toolbar
User form Toolbar
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.
Project Explorer
Docked on the right side of the screen, just under the toolbar, is the Project Explorer window. The Project Explorer as shown in in figure servers as a quick reference to the various elements of a project namely form, classes and modules. The Project Explorer window also lists code modules and classes.
Figure 3 Project Explorer
Properties Window
The Properties Window is docked under the Project Explorer window. The Properties Window exposes the various characteristics of selected objects. Each and every form in an application is considered an object. Now, each object in Visual Basic has characteristics such as color and size. Other characteristics affect not just the appearance of the object but the way it behaves too. All these characteristics of an object are called its properties. Thus, a form has properties and any controls placed on it will have propeties too. All of these properties are displayed in the Properties Window.
Object Browser
The Object Browser allows us to browse through the various properties, events and methods that are made available to us. It is accessed by selecting Object Browser from the View menu or pressing the key F2. The left column of the Object Browser lists the objects and classes that are available in the projects that are opened and the controls that have been referenced in them. It is possible for us to scroll through the list and select the object or class that we wish to inspect. After an object is picked up from the Classes list, we can see its members (properties, methods and events) in the right column.
Editor Tab
This tab controls the Code window and Project Explorer settings.
Auto Syntax Checker - Determines whether Visual Basic should automatically verify correctsyntaxafteryouenteralineofcode.ThisisusefulwhenyouarelearningVBA initially although once you are familiar with the syntax and you are editing lots of codeyou may want to switch thisoff. Whenthisisunchecked, thelineisdisplayedin adifferentcolour (red bydefault) toindicateasyntaxerror.Formoredetails,please refer to the Syntax > Auto Syntax Check page. This is ticked by default. Require Variable Declaration - This should definitely be checked as it prevents
incorrectvariablesfrombeingdefinedinyourcode. Selectingthischeckbox will automatically add the statement Option Explicit to any new modules (not existing ones). Whenthis statement isusedyoumust explicitlydeclare all your variables before using them. This is not ticked by default.
AutoListMembers-Thisshoulddefinitelybecheckedasitwillassistyouinfinding the correct properties and methods for any objects. You can insert the relevant propertyormethodbyselectingthenbypressingTab.Thisistickedbydefault. Auto Quick Info - This should definitely be checked as it displays information about functions and their corresponding parameters. This is a feature of Intellisense. This is ticked by default.
Editor Format Tab
This tab controls how your code will look in the Code window.
All theseoptionsallow you to control thetext colour andbackground colours for various items in your Code Window.
Most people do not change these options.
Colour Code - It is possible to customise the formatting for all these items: Normal Text,Selection Text, Syntax ErrorText, ExecutionPoint Text, BreakPointText, CommentText, Keyword Text,Identifier Text,Bookmark Text,CallReturnText.
Foreground - This is the colour that specifies the Text colour. Background - This is the colour that specifies the Background colour of the text. Indicator - This is the colour of the margin indicator that will appear next to that particular item.
Font - The font used to display your code. The default font is Courier New (Western). Tomakeyourcodeeasytoreadyoushouldalwaysuseafixed-widthfont,(ieall characters havethe same width).
Size - The font size used to display your code. The default font size is 10. Margin Indicator Bar - This is the margin that appears on the left of your code
module. Thisoptionlets you toggle whether the marginindicator bar is visibleor not.
General Tab
This tab controls debugging and error handling settings.
Show Grid - Determines whether to display a grid on a userform. This can be useful as it can help you to align controls. This is ticked by default.
Width - The width of the grid cells from 2 to 60 points. The default is 6. Height - The height of the grid cells from 2 to 60 points. The default is 6. AlignControls toGrid -Automaticallypositions theouteredgesofcontrolsongrid lines.
NotifyBeforeStateLoss-Determineswhetheryouwill receiveamessagenotifying youthatanaction willcausethe all modulelevel variables toberesetbeforerunning a project. This is not ticked by default.
Docking Tab
This tab controls which of the windows are dockable and which are floating.
.
When a window is dockable itcan be anchored to one of the sides of the Visual Basic Editor.
Whenever you move a dockable window a rectangle will appear to show you where it will be docked if released from the current position.
These are global settings used across Excel, Word, PowerPoint, Access and Outlook.
Visual development & event driven Programming - Methods and events.
The Click Event
The Double Event
Mouse Up and Mouse Down Events
The Mouse Move Event
The Change Event
The Key Press Event
The GotFocus and LostFocus Event
The End
Controls
When a dialog box or user form is displayed to the user, the user interacts by using various controls.
The most common controls are button, option button, listbox and edit box. It ispossibleto createyour own custom dialogboxes byaddingcontrols to a user form.
This section covers all the different controls which are available. There is a different section dedicated to Userforms
Comments
This control allows the user to either select or deselect an o Createsaboxthat theusercaneasilychooseto indicateif choices when the user can choose more than one.
Thiscontrolallowstheuser toeitherselectanitem fromth the textbox.
Allows youtodraw acombination listbox andtext box. Th enter a value in the text box.
Thiscontrolallowstheuser toperformaspecific actionand Creates a buttontheuser canchooseto carryoutacomma
Thiscontrolallowstheuser toselectadate(or time) using
Thiscontrolallowsyoutogroupothercontrols together,su Allows you to create a graphical or functional grouping for and then draw controls inside the frame.
This control allows you to add a graphic or picture to a use Displays a graphical image from a bitmap, icon, or metafile control can only be decorative and use fewer resources tha
Thiscontrolallowsyoutodisplay text totheuser.This isno Allows you to have text that you do not want the user to ch
This control allows the user to select from a list of possible Use to display a list of items from which the usercanchoos can be displayed at one time.
Thiscontrolallowstheuser toselect fromalistof possible
Thiscontrolallowstheuser toselectadate(or time) using
Thiscontrolcanbeusedtocreateadialogbox containing them.
Presents multiple screens ofinformationasa single set.
Thiscontrolallowstheuser toselect fromalistof possible Allowsyoutodisplaymultiplechoicesfrom whichtheuser
This control indicates the progress of an action by displayin
This control allows the user to select a range of cells in Exce
This control allows the user to drag a button in order to sel Provides a graphical tool for quickly navigating through a l for indicating the current position on a scale,orasaninput
Thiscontrolallowstheuser toselectavalueby clickingon value.
A spinner control youcan use with another control to incre to scroll back and forth through a range of values or a list o
Thiscontrolallowsyoutocreateseveraltabsofthe samec Allows you to define multiple pages for the same area of a
Thiscontrolallowsyoutodisplay textandtoallowthe user Holds text that the user can either enter or change.
This control allows the user to toggle between two states. Creates a button that toggles on and off.
This control displays a hierarchical list of items by using col
No comments:
Post a Comment