Unit-1. Components of.net Framework. 1. Introduction to.net Framework

Size: px
Start display at page:

Download "Unit-1. Components of.net Framework. 1. Introduction to.net Framework"

Transcription

1 1 Unit-1 1. Introduction to.net Framework The.NET framework is a collection of all the tools and utilities required to execute the.net managed applications on a particular platform. The MS.NET framework includes the standard compilers (C#, VB.NET, J#, C++.NET, Jscript.NET), various utilities like (caspol, ngen, installutil, tlbimp, sn, asmreg, ildasm, etc), runtime environment (CLR), garbage collector, security manager, thread manager, assembly loader, just in time compilers, and the standard framework or base class libraries. The.NET Framework is an environment for building, deploying, and running Web Services, Enterprise applications, and other mid and small size applications. The key components of the.net Framework are CLR and the.net Framework class library. The.NET Framework is a managed, type safe, multi-language environment for application development and execution. It provides rich tools, enhanced IDE, better runtime services with help of Web services, ADO.NET and completes XML support. Figure: Microsoft.NET Framework (i) Components of.net Framework Common Language Runtime (CLR):

2 2 The most important part of the.net Framework is the.net Common Language Runtime (CLR) also called.net Runtime in short. The.NET Framework provides a runtime environment called the Common Language Runtime or CLR (similar to the Java Virtual Machine or JJVM VM in Java), which handles the execution of code and provides useful services for the implementation of the program. It is a framework layer that resides above the Operating System and handles/manages the execution of the.net applications. Our.Net programs ms don t directly communicate with the Operating System but through CLR. CLR CLR takes care of code management at program execution and provides various beneficial services such as: a) b) c) d) e) Memory management Thread management Security management Code verification Compilation and other system services. Figure: CLR MSIL (Microsoft Intermediate Language) Code: When we compile our.net Program using any.net compliant language like (C#, VB.NET, C++.NET) it does not get converted into the executable binary code but to an intermediate code, called MSIL or IL in short, understandable by CLR. MSIL is an OS and H/w independent code. When the program needs to be executed, this MSIL or intermediate code is converted to binary executable code, called native code. The presence ce of IL makes it possible the Cross Language Relationship as all the.net compliant languages produce the similar standard IL code.

3 3 Just In Time Compilers (JITers) When our IL compiled code needs to be executed, CLR invokes JIT compilers which compile the IL code to native executable code (.exe or.dll) for the specific machine and OS. JITers in many ways are different from traditional compilers as they, as their name suggests, compile the IL to native code only when desired e.g., when a function is called, IL of function s body is converted to native code; just in time of need. Framework Class Library (FCL).NET Framework provides huge set of Framework (or Base) Class Library (FCL) for common, usual tasks. FCL contains thousands of classes to provide the access to Windows API and common functions like String Manipulation, Common Data Structures, IO, Streams, Threads, Security, Network Programming, Windows Programming, Web Programming, Data Access, etc. It is simply the largest standard library ever shipped with any development environment or programming language. The best part of this library is they follow extremely efficient OO design (design patterns) making their access and use very simple and predictable. You can use the classes in FCL in your program just as you use any other class and can even apply inheritance and polymorphism on these. The.NET Framework class library is made up of namespaces, which are contained within assemblies. Namespaces are used to create logical groups of related classes and interfaces that can be used by any language that targets the.net Framework. An assembly contains all the information about the implementation of classes, structures, and interfaces. It is a single deployable unit that stores all the information about itself. This information is known as metadata and includes name and version number of the assembly, security information, dependency information, and a list of the files that constitute the assembly. Common Language Specification (CLS) Microsoft has released a small set of specification that each language should meet to qualify as a.net Compliant Language. As IL is a very rich language, it is not necessary for a language to implement all the IL functionality, rather it meets the small subset of it, CLS, to qualify as a.net compliant language, which is the reason why so many languages (procedural and OO) are now running under.net umbrella. CLS basically addresses to language design issues and lays certain standards like there should be no global function declaration, no pointers, no multiple inheritance and things like that. The important point to note here is that if you keep your code within CLS boundary, your code is guaranteed to be usable in any other.net language. Common Type System (CTS)

4 4.NET also defines a Common Type System (CTS). Like CLS, CTS is also a set of standards. CTS define the basic data types that IL understands. Each.NET compliant language should map its data types to these standard data types. This makes it possible for the 2 languages to communicate with each other by passing/receiving parameters to/from each other. For example, CTS defines a type Int32, an integral data type of 32 bits (4 bytes) which is mapped by C# through int and VB.Net through its Integer data type. Garbage Collector (GC) CLR also contains Garbage Collector (GC) which runs in a low-priority thread and checks for unreferenced dynamically allocated memory space. If it finds some data that is no more referenced by any variable/reference, it re-claims it and returns the occupied memory back to the Operating System; so that it can be used by other programs as necessary. The presence of standard Garbage Collector frees the programmer from keeping track of dangling data. (ii) Advantages/Features of the.net Framework Some advantages offered by the.net Framework are: 1. Consistent programming Model: The.Net Framework provides a common object oriented programming model across languages. This object model can be used to perform several tasks, such as reading from and writing to files, connecting to databases, and retrieving data. 2. Multi-platform applications: There are several versions of windows, most of which run on X86 microprocessors. Some versions, such as Windows CE and 64-bit Windows, run on non-x86 microprocessors as well. A.Net application can execute on any architecture provided it is supported by the CLR. 3. Simplified Development Efforts: In Web application, a developer with classic ASP needs to present data from a database in a web page. He has to write the application logic (code) and presentation logic (design) in the same file. ASP.NET and the.net Framework simplify development by separating the application logic and presentation logic making it easier to maintain the code. 4. Rich Functionality out of the box: NET framework provides a rich set of functionality out of the box. It contains hundreds of classes that provide variety of functionality ready to use in your applications. This means that as a developer you need not go into low level details of many operations such as file IO, network communication and so on. 5. Easy development of web applications: ASP.NET is a technology available on.net platform for developing dynamic and data driven web applications. ASP.NET provides an event driven programming model (similar to Visual Basic 6 that simplify development of web pages (now called as

5 5 web forms) with complex user interface. ASP.NET server controls provide advanced user interface elements (like calendar and grids) that save lot of coding from programmer s side. 6. OOPs Support: The advantages of Object Oriented programming are well known..net provides a fully object oriented environment. The philosophy of.net is Object is mother of all. Languages like Visual Basic.NET now support many of the Object Oriented features that were lacking traditionally. Even primitive types like integer and characters can be treated as objects something not available even in Object oriented languages like C Multi-Language Support:.NET allows multiple languages to be integrated. For example, it is possible to create a class in C# to that derives from a class implemented in Visual Basic. The.NET Framework enables objects to interact with each other regardless of the language used to develop them. 8. Multi-Device Support: Modern life style is increasingly embracing mobile and wireless devices such as PDAs, mobiles and handheld PCs..NET provides promising platform for programming such devices..net Compact Framework and Mobile Internet Toolkit are step ahead in this direction. 9. Automatic resource management: While creating an application, a programmer may be required to write code for managing resource s such as files, memory, network connections, and database resources. If a programmer does not free these resources, the application may not execute properly. The CLR automatically manages resources such as files, memory, network connections, and database resources. That relieves the programmer from having to manage those resources manually. 10. Compatibility with COM and COM+: Before the introduction of.net, COM was the de-facto standard for componentized software development. Companies have invested lot of money and efforts in developing COM components and controls. The good news is you can still use COM components and ActiveX controls under.net. This allows you to use your existing investment in.net applications..net still relies on COM+ for features like transaction management and object pooling. In fact it provides enhanced declarative support for configuring COM+ application right from your source code. Your COM+ knowledge still remains as a valuable asset. 11. Strong XML support: Now days it is hard to find a programmer who is unaware of XML. XML has gained such a strong industry support that almost all the vendors have released some kind of upgrades or patches to their existing software to make it XML compatible. Currently,.NET is the only platform that has built with XML right into the core framework..net tries to harness power of XML in every possible way. In addition to providing support for manipulating and transforming XML documents,.net provides XML web services that are based on standards like HTTP, XML and SOAP. 12. Ease of deployment and configuration. Deploying windows applications especially that used COM components were always been a tedious task..net Framework has simplified the task of application deployment..net application can be deployed simply by coping files to the target. In the.net

6 6 Framework, applications are deployed in the form of assemblies. An assembly stores metadata. Therefore, registry entries are not required for storing information about the versions of components used by an application. The configuration is done via special files having special XML vocabulary. Since, most of the configuration is done via configuration files, there is no need to sit in front of actual machine and configure the application manually. This is more important for web applications. 13. Security: Windows platform was always criticized for poor security mechanisms. Microsoft has taken great efforts to make.net platform safe and secure for enterprise applications. Features such as type safety, code access security and role based authentication make overall application more robust and secure. 2. VB.NET Concept (i) GUI GUI stands for Graphical User Interface. It is a way for user to interact with computers or application that uses windows, icons and menus and which can be manipulated. It refers to the graphical interface of a computer that allows users to click and drag objects with a mouse instead of entering text. GUI aims to provide users with an interface that is easy to use. The interface provided by IDE (Integrated Development Environment). Windows applications rely on a GUI to interact with user using the mouse and the keyboard. It is easy to execute commands using the GUI. Windows applications provide GUIs that enable user interaction for the application to execute. The following are the types of interaction interfaces that are supported by the.net framework: Web Forms Windows Forms Web Services (ii) Event Driven Programming/Event Driven Environment Event driven programming or event-based programming is a programming in which the flow of the program is determined by events or user actions (mouse clicks, key presses) or messages from other programs. The style of programming which responds to user events and is driven by occurrence of user events is called as Event driven programming. When an interface component is used, programmer decides what action is to be taken and write code that will be executed when event occurs. Each interface component can have multiple events. In event driven

7 7 programming, an application is built up as series of responses to user events. The code that gets executed in response to an event is called Event Handler. The code gets executed only in response to a user event. 3. VB.NET IDE (Integrated Development Environment) The Studio.NET IDE provides a common interface for developing Windows and Web-based applications. The IDE provides a centralized location for designing a user interface, writing code and compiling and debugging the application. The VB.Net IDE consists of a set of Graphical User Interfaces (GUIs) and components. The Visual Studio.NET IDE is available to all programmers who use languages in the Visual Studio. When we open Microsoft Visual Studio 2008 from Start->Programs->Microsoft Visual Studio 2008>Microsoft Visual Studio 2008 the window that is displayed first is the Start Page which is shown below. The start Page allows us to select from the most recent projects with which we worked or it can be customized based on your preferences. Figure: Start Page

8 8 The Integrated Development Environment (IDE) shown in the image below is what we actually work with. This IDE is shared by all programming languages in Visual Studio. You can view the toolbars towards the left side of the image along with the Solution Explorer window towards the right. Figure: Integrated Development Environment The following are the components of Visual Studio.NET IDE. Title Bar Menu Bar Tool Bar Windows Form Designer Solution Explorer Toolbox Properties Window Server Explorer Output Window Code Window Task List Window Class View Window

9 9 Object Browser Title Bar It shows the title of the VB.Net project you are currently working on. The default project title is the project name you have specified when you create a new project. If you would like to change the project name or title to other name, you can change it through Project -> Project Properties. Menu Bar It consists of menus that help you manipulate VB.Net programs in the project. The menus are listed from left to right as File, Edit, View, Project, Build, Debug, Tools, Window, and Help. Tool Bar The Tool Bar gives us quick access to commonly used Menu Commands. You can add more toolbars. The steps to do that are Select Views->Toolbars and Check on the names of the toolbars. Windows Form Designer

10 10 The Windows Forms Designer allows you to design the user interface. It allows you to add controls to a form, arrange them according to your requirements, and add code to perform actions. The window is a blank window (or form) on which you can place controls. The form and its controls constitute the graphical user interface (GUI) of a VB.Net program. They are the visual part of the program with which the user can interact. As a result, the Windows Forms Designer provides you with a rapid development solution for your application. Figure: Windows Form Designer Window Solution Explorer The Solution Explorer window lists the solution name, the project name, and the various forms and modules for a project. The Solution Explorer provides you with an organized view of your project and program files associated with the project. The Solution Explorer window is shown in figure. To open a file in a project, double click the file in the Solution Explorer.

11 11 Figure: Solution Explorer Toolbox Window The window is very important in the VB.Net IDE. It contains the control or components that can be used in application, such as Textboxes, labels, buttons, radio buttons, checkboxes etc. The Toolbox window displays a number of tabs. Each tab contains several items, including Pointer, Label, LinkLabel, and Button etc. Figure displays the items available on the Toolbox window. Figure: Toolbox

12 12 The Toolbox contains the Data, Components, Windows Forms, Containers, Common Controls, Printing, Menus and Toolbars and Reporting etc. Each of these tabs contains items. Properties Window The properties window allows us to set properties for various objects at design time. The properties window displays the properties for a form or a control. For example, if you want to change the font, font size, back-color, name, text that appears on a button, textbox etc. Properties describe attributes such as size, color, and font of a control. Each form or control has its own set of properties. When you click on a control or the form, the properties will be listed in the properties window. There are two columns in the properties window. The first column lists the property names and the second column shows the current value of the property. The value can be changed at the design phase of the form or through the program code.

13 13 Figure: Properties Window Server Explorer The Server Explorer window is a great tool that provides "drag and drop" feature and helps us work with databases in an easy graphical environment. For example, if we drag and drop a database table onto a form, VB.NET automatically creates connection and command objects that are needed to access that table. The Server Explorer window enables you to perform various administrative tasks such as monitoring the performance of other machines on the network and locating and connecting to available servers. The Server Explorer window is shown in figure.

14 14 Figure: Sever Explorer Window Output Window The Output Window displays status messages for features in the visual Studio.NET IDE. For example, when you compile an application, the Output window displays the current status, and after the compilation process is complete, it specifies the number of errors that occurred during compilation. The Output window is shown in figure. Figure: Output Window

15 15 Code Window/Code Designer Window Code Designers allows us to edit and write code. This is the window that opens when we double-click on a form or any control. This is the place where we write all the code for the application. The F7 key allows you to switch from the form s design view to its corresponding Code Designer Window. Task List Window Figure: Code Window The task list window displays all the tasks that VB.NET assumes we still have to finish. You can view the task list window by selecting View->Other Windows->Task List from the main menu. Class View Window The class view window is the window that presents solutions and projects in terms of the classes they contain and the members of these classes. Using the class view window also helps us to find a member of a class that we want to work with. The Class View Window displays the classes, methods, and properties associated with files. Object Browser Window/Object Explorer Window The object explorer window allows us to view all the members of an object at once. The Object Browser allows you to examine and discover objects (namespaces, classes, structures, interfaces, types, enums, etc.)

16 16 and their members (properties, methods, events, variables, constants, enum items etc.) from various components. There are three Panes: an object pane on the left, a member pane on the upper right, and a description pane on the lower right. The image below displays an Object Browser window. You can open the Object Browser window from the View Menu, or by clicking the Object Browser button on the main toolbar or by pressing F2. Figure: Object Browser Window 4. Windows Forms A Windows form represents a window displayed in an application. A Windows form is used to accept user input and display data. For example, in an airline reservation application, users need to provide details,

17 17 such as the destination, date of travel, and the number of seats required. Users can specify these details by using a Windows form. Windows forms are created using the System.Windows.Forms.Form class, described in the System.Windows.Forms namespace. The System.Windows.Forms namespace contains a number of classes, and is used to create components, controls, forms, and dialog boxes. (i) Windows Forms Events An event is generated when a user perform an action, such as clicking the mouse. For example, when a user clicks the mouse on the Windows form, the Click event is generated. Windows form and all the controls on the form have specific events associated with them. You can write a code to instruct an application to perform a specific action when an event takes place. Some events associated with a Windows form are explained below. 1. Activated: This event occurs when the form is activated in the code or by the user. 2. Click: This event occurs when a user clicks on a form or any control in the form. 3. Deactivate: This event occurs when the form loses its focus and is not the active form. 4. FormClosed: This event occurs when the form is being closed. 5. FormClosing: This event occurs when the form is closing. 6. Load: This event occurs before a form is displayed for the first time. 7. MouseDown: This event occurs when the left mouse button is pressed on a Windows form. 8. MouseMove: This event occurs when a mouse is moved over a form. 9. MouseUp: This event occurs when the mouse button is released on the Windows form. 10. Move: This event occurs when the form is moved. (ii) Windows Form Properties The properties window allows us to set properties for Form at design time. The properties window displays the properties for a form. Properties describe attributes such as BackColor, Name and font of a Form. These are the some properties of a Form. AcceptButton: Get or sets the form button if the enter key is pressed. AllowDrop: Specifies whether to accept the data dragged and dropped onto the form. AutoScroll: Indicates whether scroll bars automatically appear when the form contents are larger than its visible area.

18 18 BackColor: Set's the background color for the form. BackgroundImage: Set's the background image for the form. BackgroundImageLayout: Set's the background image layout for the background image in the form. The BackgroundImageLayout values are Tile, Centre, Stretch, Zoom. Cursor: Set the cursor image when it hovers over the form. Control Box: The ControlBox property decides whether the form will have a control Box or not. It is an enumerated type property with only two possible values: True and False. The default value is True. Enabled: Whether the form is enabled. Its default value is true. Font: Get or sets the font used in the form. ForeColor: Sets the foreground colour, which is used to display text. FormBorderStyle: Get or set border style of a form. Icon: Specifies icon for the window on the upper left corner. IsMDIChild: Defines whether the form is a container of Multiple Document Interface (MDI) child form. Language: Specifies the localized language. Location: Sets the coordinates of the upper-left corner of the form relative to the upper-left corner of its container. Locked: The Locked property determines if we can move or resize the form. MaximizeBox: Specifies whether to display the maximize option in the caption bar of the form. It is an enumerated type property. It has only two possible values, namely True and False. The default value of this property is True. MinimizeBox: Specifies whether to display the minimize option in the caption bar of the form. It is an enumerated type property. It has only two possible values, namely True and False. The default value of this property is True. Name: Indicates the name used in the code to identify the form. Text: Provide the title for a Form Window.

19 19 WindowState: Determines the initial visual state of the form. (iii) Windows Form Methods The form is implemented by the Form class from the System.Windows.Forms namespace. The Form class is equipped with a constructor that allows you to dynamically create it. After a form has been created, it must be loaded to display on the screen. There is various Form s method in Visual Basic.net Show: To display a form the Show() method is used and to hide a form Hide() method is used. This method is used to display the form on top of all other windows even if it is loaded or not loaded into the memory. Syntax: FormName.Show In the above syntax, the Show method can also have argument values 0 or 1 for Modeless or Modal forms. By default this methods modeless or normal forms, but the modal forms more interactive. 2. Hide: This method hides a form object from the screen, still with the object being loaded in the memory. Syntax: FormName.Hide Example: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click DisplayForm.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

20 20 DisplayForm.Hide() End Sub End Class 3. Activate: This method Activates the form and gives it focus. Syntax: Form1.Activate() 4. Close: This method is used to close the form. Syntax: Form1.Close () 5. ShowDialog: This method is used to show the form as a modal dialog box. Synatx: Form1.ShowDialog() 6. Focus: This method is used to sets input focus to the control. Synatx: Form1.focus() 7. ResetText: This method is used to resets the Text property to its default value. Synatx: Form1.ResetText() 5. Intrinsic Controls The controls that appear first in the Toolbox Window are called Intrinsic Controls. A control is a component in a windows form used to accept input or display data. When you interact with a particular control, a specific event occurs that is handled by the corresponding event handler. Windows forms support various types of controls. Controls have a variety of variety of properties, methods, and events for performing a specific task. Some of the intrinsic controls are:

21 21 Label: You use the Label tool to create a label control. The purpose of a label control is to display text that the user is not allowed to edit while the application is running. Properties of the Label Control AutoSize: This property is used to set or get a value specifying the control should be automatically resized. BackColor: BackColor properties are used to set background color of the Label. BorderStyle: This property is used to set or get the border style for the control. Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enable: Determines whether or not the control can respond to user-generated events. FlatStyle: Sets/gets the flat style appearance of the label control. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the label, which is used to display text. Image: Property is used to set or get the image that is displayed on a label. ImageAlign: Property is used to set or get the alignment of an image that is displayed in the control. Location: The Location property takes a Point that specifies the starting position of the Label on a Form. Locked: The Locked property determines if we can move or resize the control. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the Label control. Width: It is used to gets or sets the width of the Label control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the label. TextAlign: The alignment of the text that will display on the control. Visible: Determines whether the control is visible or hidden.

22 22 Button: The Button control represents a standard Windows button. It is generally used to generate a Click event by providing a handler for the Click event. It is used to perform an action when you click it. Properties of the Button Control AutoSize: The AutoSize property will (if enabled) resize the button to fit its contents. BackColor: BackColor properties are used to set background color of the Button. BackgroundImage: The background image used for the control. BackgroundImageLayout: The BackgroundImageLayout property will change the way the BackgroundImage displays. Cursor: The Cursor property controls what type of cursor is displayed when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. FlatStyle: It determines the appearance of the control when a user moves the mouse over the control and clicks. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the button, which is used to display text. Image: It specifies the image that will be displayed on the button. ImageAlign: Property is used to set or get the alignment of an image that is displayed in the control. Location: The Location property is the X and Y value of the position on the form. Locked: The Locked property determines if we can move or resize the control. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the button control. Width: It is used to gets or sets the width of the button control.

23 23 TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the button. TextAlign: The alignment of the text that will display on the control. Visible: Determines whether the control is visible or hidden. Checkbox: CheckBox allow the user to make multiple selections from a number of options and CheckBox comes with a caption, which you can set in the Text property. The CheckBox has a square box and a text string. When a checkbox is selected a check (a tick mark) appears indicating a selection. When a check box is selected it has the value True, and when it is cleared, it holds the value False. Properties of the CheckBox Control AutoCheck: It causes the check box to automatically change state when clicked. AutoSize: It specifies whether a control will automatically size itself to fit its contents. BackColor: BackColor properties are used to set background color of the CheckBox. BackgroundImage: The background image used for the control. BackgroundImageLayout: The BackgroundImageLayout property will change the way the BackgroundImage displays. CheckAlign: It determines the location of the check box inside the control. Checked: This property is used to set or get the value indicating if the checkbox is in checked state. CheckState: This property is used to get or set the state of a check box. Cursor: The Cursor property controls what type of cursor is displayed when the pointer moves over the control.

24 24 Dock: It defines which border of the control is bound to the container. Enabled: It determines whether or not the control can respond to user-generated events. FlatStyle: It determines the appearance of the control when a user moves the mouse over the control and clicks. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the checkbox, which is used to display text. Image: It specifies the image that will be displayed on the CheckBox. ImageAlign: Property is used to set or get the alignment of an image that is displayed in the control. Location: The Location property is the X and Y value of the position on the form. Locked: The Locked property determines if we can move or resize the control. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the CheckBox control. Width: It is used to gets or sets the width of the CheckBox control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the CheckBox. TextAlign: The alignment of the text that will display on the control. Visible: Determines whether the control is visible or hidden. ComboBox: The ComboBox control is used to display a drop-down list of various items. It is a combination of a text box in which the user enters an item and a drop-down list from which the user selects an item. Properties of the ComboBox Control BackColor: The BackColor property is used to set background color of the ComboBox.

25 25 Cursor: The Cursor property controls what type of cursor is displayed when the pointer moves over the control. DataSource: It indicates the list that this control will use to get its items. DisplayMember: It indicates the property to display for the items in this control. DropDownStyle: It controls the appearance and functionality of the ComboBox. Dock: It defines which border of the control is bound to the container. Enabled: It determines whether or not the control can respond to user-generated events. FlatStyle: It determines the appearance of the control when a user moves the mouse over the control and clicks. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the ComboBox, which is used to display text. FormatString: Gets or sets the format-specifier characters that indicate how a value is to be displayed. Items: Gets an object representing the collection of the items contained in this ComboBox. Height: It is used to gets or sets the height of the combo box control. Location: The Location property is the X and Y value of the position on the form. Locked: The Locked property determines if we can move or resize the control. Size: The Size property specifies the size of the control. Sorted: Gets or sets a value indicating whether the items in the ComboBox are sorted. Width: It is used to gets or sets the width of the ComboBox control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the ComboBox. Visible: Determines whether the control is visible or hidden. RadioButton: The RadioButton control is used to provide a set of mutually exclusive options. The user can only choose one item only out of a number of choices in a group. If you need to place more than one group of radio buttons in the same form, you should place them in different container controls like a GroupBox control.

26 26 Properties of the RadioButton Control AutoCheck: It causes the radio button to automatically change state when clicked. AutoSize: It specifies whether a control will automatically size itself to fit its contents. BackColor: The BackColor property is used to set background color of the radio button. BackgroundImage: The background image used for the control. BackgroundImageLayout: The BackgroundImageLayout property will change the way the BackgroundImage displays. CheckAlign: It determines the location of the check box inside the control. Checked: It indicates whether the radio button is checked or not. Cursor: The Cursor property controls what type of cursor is displayed when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enabled: It determines whether or not the control can respond to user-generated events. FlatStyle: It determines the appearance of the control when a user moves the mouse over the control and clicks. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the radio button, which is used to display text. Image: It specifies the image that will be displayed on the radio button. ImageAlign: Property is used to set or get the alignment of an image that is displayed in the control. Location: The Location property is the X and Y value of the position on the form. Locked: The Locked property determines if we can move or resize the control.

27 27 Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the RadioButton control. Width: It is used to gets or sets the width of the RadioButton control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the RadioButton. TextAlign: The alignment of the text that will display on the control. Visible: Determines whether the control is visible or hidden. ListBox: This is similar to the ComboBox control. The difference is that in a c control you are allowed to select more than one option because of the SelectionMode property. The ListBox control has a scrollbar to move through its options. You can populate the list box items either from the properties window or at runtime. Properties of the ListBox Control BackColor: The BackColor property is used to set background color of the ListBox. BorderStyle: It controls what type of border is drawn around the ListBox. Cursor: The Cursor property controls what type of cursor is displayed when the pointer moves over the control. DataSource: It indicates the list that this control will use to get its items.

28 28 DisplayMember: It indicates the property to display for the items in this control. Dock: It defines which border of the control is bound to the container. Enabled: It determines whether or not the control can respond to user-generated events. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the ListBox, which is used to display text. FormatString: Gets or sets the format-specifier characters that indicate how a value is to be displayed. Items: Gets an object representing the collection of the items contained in this ListBox. Height: It is used to gets or sets the height of the ListBox control. Location: The Location property is the X and Y value of the position on the form. Locked: The Locked property determines if we can move or resize the control. MultiColumn: Gets or sets a value indicating whether the list box supports multiple columns. ScrollAlwaysVisible: It indicates if the list box should always have a scroll bar present regardless of how many items are in it. SelectionMode: It indicates if the list box is to be single-select, multi-select, or not selectable. Size: The Size property specifies the size of the control. Sorted: Gets or sets a value indicating whether the items in the list box are sorted. Width: It is used to gets or sets the width of the list box control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the ListBox. Visible: Determines whether the control is visible or hidden. TextBox: Text box controls allow entering text on a form at runtime. This is one of the most used controls, as text is vital for GUI based applications. The Text property of a TextBox is used to retrieve information from the TextBox. By default, a TextBox will only display text on a single line. If you require more than one line you can set it's Multiline property to true.

29 29 Properties of the TextBox Control BackColor: The BackColor property is used to set background color of the TextBox. BorderStyle: This property is used to set or get the border style for the control. Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enable: Determines whether or not the control can respond to user-generated events. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the textbox, which is used to display text. Height: It is used to gets or sets the height of the TextBox control. Location: The Location property takes a Point that specifies the starting position of the TextBox on a Form. Locked: The Locked property determines if we can move or resize the control. Multiline: This property is used to set more than one line text. PasswordChar: It indicates the character to display for password for single line TextBox control. ReadOnly: It controls whether the text in the textbox control can be changed or not. ScrollBars: Gets or sets which scroll bars should appear in a multiline TextBox control. This property has values: None, Horizontal, Vertical, Both. Size: The Size property specifies the size of the control. Width: It is used to gets or sets the width of the TextBox control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the TextBox. TextAlign: The alignment of the text that will display on the control. Visible: Determines whether the control is visible or hidden.

30 30 LinkLabel: A LinkLabel control is a label control that can display a hyperlink. A LinkLabel control is inherited from the Label class so it has all the functionality provided by the Windows Forms Label control. LinkLabel control does not participate in user input or capture mouse or keyboard events. Properties of the LinkLabel Control AutoSize: It enables automatic resizing based on font size. BackColor: The BackColor property is used to set background color of the LinkLabel. BorderStyle: This property is used to set or get the border style for the control. Cursor: The cursor that appears when the pointer moves over the control. DisableLinkColor: It determines the color of the hyperlink when disabled. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the LinkLabel, which is used to display text. Height: It is used to gets or sets the height of the LinkLabel control. Image: The image that will be displayed on the control. ImageAlign: Property is used to set or get the alignment of an image that is displayed in the control. LinkBehavior: It determines the underline behavior of the hyperlink. LinkColor: Property is used to specify the color for a normal link. Location: The Location property takes a Point that specifies the starting position of the Label on a Form. Locked: The Locked property determines if we can move or resize the control. Size: The Size property specifies the size of the control. Width: It is used to gets or sets the width of the LinkLabel control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the LinkLabel.

31 31 TextAlign: The alignment of the text that will display on the control. Visible: Determines whether the control is visible or hidden. VisitedLinkColor: Property is used to specify the color for a visited link. ScrollBars: The ScrollBar controls display vertical and horizontal scroll bars on the form. This is used for navigating through large amount of information. There are two types of scroll bar controls: HScrollBar for horizontal scroll bars and VScrollBar for vertical scroll bars. These are used independently from each other. Let's click on HScrollBar control and VScrollBar control from the Toolbox and place them on the form. Properties of HScrollBar and VScrollBar Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. Height: It is used to gets or sets the height of the ScrollBar control.

32 32 LargeChange: When the user presses the PAGE UP or PAGE DOWN key or clicks in the scroll-bar track on either side of the scroll box, the Value property changes according to the value set in the LargeChange property. Location: The Location property takes a Point that specifies the starting position of the ScrollBar on a Form. Locked: The Locked property determines if we can move or resize the control. Maximum: This Property used to set or get upper limit of the scrollable range. Minimum: This Property used to set or get lower limit of the scrollable range. SmallChange: Property used to set or get lower limit of the scrollable range. Size: The Size property specifies the size of the control. Width: It is used to gets or sets the width of the ScrollBar control. TabIndex: Determines the index in the TAB order that this control will occupy. Text: The text property indicates the text which will be displayed on the ScrollBar. Value: The value that the scroll box position represents. Visible: Determines whether the control is visible or hidden. ListView: The ListView control is used to display a list of items. Along with the TreeView control, it allows you to create a Windows Explorer like interface. The ListView control displays a list of items along with icons. The Item property of the ListView control allows you to add and remove items from it. Properties of ListView Alignment: It indicates how items are aligned within the ListView. Backcolor: This Property used to set the background color. BackgroundImage: The background image used for the control. BorderStyle: This property is used to set or get the border style for the control. CheckBoxes: It indicates whether check boxes are displayed beside items. Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container.

33 33 Enabled: Determines whether or not the control can respond to user-generated events. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: It specifies the foreground color of the ListView, which is used to display text. Items: Gets a collection containing all items in the control. Location: The Location property takes a Point that specifies the starting position of the ListView on a Form. Locked: The Locked property determines if we can move or resize the control. MultiItem: It allows multiple items to be selected. Scrollable: Gets or sets a value indicating whether a scroll bar is added to the control when there is not enough room to display all items. Size: The Size property specifies the size of the control. Sorting: It indicates the manner in which items are to be sorted. TabIndex: Determines the index in the TAB order that this control will occupy. Visible: It determines whether the control is visible or hidden. PictureBox: 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 and at run time. Properties of PictureBox:

34 34 BackColor: The BackColor properties are used to set background color of the PictureBox. BackgroundImage: The background image used for the control. BorderStyle: This property is used to set or get the border style for the control. Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. Image: Property is used to set or get the image that is displayed in PictureBox. ImageLocation: Disk or web location to load image from. Location: The Location property takes a Point that specifies the starting position of the PictureBox on a Form. Locked: The Locked property determines if we can move or resize the control. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the PictureBox control. Width: It is used to gets or sets the width of the PictureBox control. SizeMode: It controls how the PictureBox will handling image and control sizing. Visible: Determines whether the control is visible or hidden. DateTimePicker: The DateTimePicker control allows selecting a date and time by editing the displayed values in the control. If you click the arrow in the DateTimePicker control, it displays a month calendar, like a combo box control. The user can make selection by clicking the required date. The new selected value appears in the text box part of the control.

35 35 The MinDate and the MaxDate properties allow you to put limits on the date range. Properties of DateTimePicker Cursor: The cursor that appears when the pointer moves over the control. CustomFormat: The custom format string used to format the date and/or time displayed in the control. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). Format: It determines whether dates and times are displayed using standard or custom formatting. Location: The Location property takes a Point that specifies the starting position of the DateTimePicker on a Form. Locked: The Locked property determines if we can move or resize the control. MaxDate: The maximum date that can be selected. MinDate: The minimum date that can be selected. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the DateTimePicker control. Width: It is used to gets or sets the width of the DateTimePicker control. TabIndex: Determines the index in the TAB order that this control will occupy. Value: The current date/time value for this control.

36 36 Visible: It determines whether the control is visible or hidden. ProgressBar: It represents a Windows progress bar control. It is used to provide visual feedback to your users about the status of some task. It shows a bar that fills in from left to right as the operation progresses. The main properties of a progress bar are Value, Maximum and Minimum. The Minimum and Maximum properties are used to set the minimum and maximum values that the progress bar can display. The Value property specifies the current position of the progress bar. The ProgressBar control is typically used when an application performs tasks such as copying files or printing documents. Properties of ProgressBar BackColor: The BackColor properties are used to set background color of the ProgressBar. Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. ForeColor: The foreground color of this component, which is used to display text. Location: The Location property takes a Point that specifies the starting position of the ProgressBar on a Form. Locked: The Locked property determines if we can move or resize the control. Maximum: Gets or sets the maximum value of the range of the control. Minimum: Gets or sets the minimum value of the range of the control. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the ProgressBar control. Width: It is used to gets or sets the width of the ProgressBar control. Style: Gets or sets the manner in which progress should be indicated on the progress bar.

37 37 TabIndex: Determines the index in the TAB order that this control will occupy. Value: Gets or sets the current position of the progress bar. Visible: Determines whether the control is visible or hidden. TreeView: The TreeView control is used to display hierarchical representations of items similar to the ways the files and folders are displayed in the left pane of the Windows Explorer. Each node may contain one or more child nodes. Properties of TreeView Control BackColor: The BackColor properties are used to set background color of the TreeView. BorderStyle: This property is used to set or get the border style for the control. Cursor: The cursor that appears when the pointer moves over the control. Dock: It defines which border of the control is bound to the container. Enabled: Determines whether or not the control can respond to user-generated events. Font: The font used to display text in the control, specifies the font (name, style, size, etc.). ForeColor: The foreground color of this component, which is used to display text. ImageList: The ImageList control from which node images are taken.

38 38 Location: The Location property takes a Point that specifies the starting position of the TreeView on a Form. Locked: The Locked property determines if we can move or resize the control. Scrollable: It indicates whether the control will display scroll bars if it contains more nodes than can fit in the visible area. Size: The Size property specifies the size of the control. Height: It is used to gets or sets the height of the TreeView control. Width: It is used to gets or sets the width of the TreeView control. TabIndex: Determines the index in the TAB order that this control will occupy. Visible: Determines whether the control is visible or hidden. 6. MsgBox and MessageBox The MsgBox Function The MsgBox function displays a message in a dialog box, waits for the user to click a button, and returns an Integer indicating which button the user clicked. Syntax: MsgBox(prompt[, buttons] [, title]) Or IntegerVariable = MsgBox(prompt[, buttons] [, title]) The MsgBox function syntax has these parts: Part Description prompt String expression displayed as the message in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. It is required to specify. buttons Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If omitted, the default value for buttons is 0 (which causes only an OK button to be displayed with no icon). It is optional.

39 39 title String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar. It is optional. You can find the possible constants to use for the Buttons arguments Constant Value Description OKOnly 0 Shows OK button only. OKCancel 1 Shows OK and Cancel buttons. AbortRetryIgnore 2 Shows Abort, Retry, and Ignore buttons. YesNoCancel 3 Shows Yes, No, and Cancel buttons. YesNo 4 Shows Yes and No buttons. RetryCancel 5 Shows Retry and Cancel buttons. Critical 16 Shows Critical Message Icon. Question 32 Shows Warning Query Icon. Exclamation 48 Shows Warning Message icon. Information 64 Shows Information Message icon. DefaultButton1 0 First button is default. DefaultButton2 256 Second button is default. DefaultButton3 512 Third button is default. ApplicationModal 0 Application modal which means the user must respond to the message box before continuing work in the current application. SystemModal 4096 System modal, which means all applications are suspended until the user responds to the message box. MsgBoxSetForeground Specifies the message box window as the foreground window. MsgboxRight Text will be right-aligned.

40 40 MsgBoxRtlReading Specifies text should appear as right-to-left on RTL systems such as Hebrew and Arabic. Example: Private Sub Button1_Click( ByVal Sender As System.Object, ByVal e as System.EventArgs) Handles Button1.Click Dim Result As Integer Result=MsgBox( This is a message box, MsgBoxStyle.OkCancel+MsgBoxStyle.Information+MsgBoxStyle.SystemModel, Example of MsgBox ) If(Result=MsgBoxResult.OK) Then TextBox1.Text= You Clicked Ok End if End Sub MessageBox:.NET has introduced a class called MessageBox which encapsulates all the features of MsgBox. The difference between MsgBox and MessageBox is that Msgbox is a function while MessageBox is a class. The MessageBox class has various overloaded Show methods for different parameters. From a practical standpoint, both the MsgBox function and the MessageBox class will accomplish the same thing. You will notice that the arguments for MessageBox are specified in a slightly different order from MsgBox. MessageBox.Show Method To show the message box we need to call the Show method of the MessageBox class, for example: MessageBox.Show("Hello World!") The syntax of the MessageBox.Show method can be looked as follows: [DialogResult = ] MessageBox.Show(prompt [, caption] [, MessageBoxButtons]

41 41 [, MessageBoxIcon] [, MessageBoxDefaultButton] [, MessageBoxOptions]) An explanation of the Show method arguments is shown below: prompt The test to display in the message box. caption The text to display in the title bar of the message box. MessageBoxButtons - Specifies which buttons to display on the message box. Possible values are: MessageBoxButtons.AbortRetryIgnore (displays the Abort, Retry, and Ignore buttons) MessageBoxButtons.OK (displays the OK button) MessageBoxButtons.OKCancel (displays the OK and Cancel buttons) MessageBoxButtons.RetryCancel (displays the Retry and Cancel buttons) MessageBoxButtons.YesNo (displays the Yes and No buttons) MessageBoxButtons.YesNoCancel (displays the Yes, No, and Cancel buttons) MessageBoxIcon - Specifies which icon to display on the message box. Possible values are: Value Icon MessageBoxIcon.Error - or - MessageBoxIcon.Hand - or - MessageBoxIcon.Stop MessageBoxIcon.Question

42 42 MessageBoxIcon.Exclamation - or - MessageBoxIcon.Warning MessageBoxIcon.Asterisk - or - MessageBoxIcon.Information None MessageBoxIcon.None MessageBoxDefaultButton - Specifies the default button for the message box. Possible values are: MessageBoxDefaultButton.Button1 (the first message box button is the default button) MessageBoxDefaultButton.Button2 (the second message box button is the default button) MessageBoxDefaultButton.Button3 (the third message box button is the default button) MessageBoxOptions - Allows specialized options to be specified. Possible values are: MessageBoxOptions.DefaultDesktopOnly (displays the message box on the active desktop) MessageBoxOptions.RightAlign (displays the message box text right-aligned) MessageBoxOptions.RtlReading (displays the text in right-to-left reading order) MessageBoxOptions.ServiceNotification (displays the message box on the active desktop, even if there is no user logged on to the computer) Example: Dim intresponse As DialogResult intresponse = MessageBox.Show _ ("Are you sure you want to " & _

43 43 "delete all of the rows " & _ "in the Customer table?", _ "Delete", _ MessageBoxButtons.YesNo, _ MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) If intresponse = DialogResult.Yes Then ' delete the rows End If 7. Programming with VB.NET: (i) Data Types The Data Type determines what type of data a variable or a constant can hold. For example, a student s name is a string, and a student s age is an integer. Visual Basic.NET provides data types to store data. VB.NET provides following data types. S.NO. Data Type Description Size 1 Byte Used to store binary numbers 1 byte 2 Boolean Used to store logical values, True and False 2 bytes

44 44 3 Char Use to store a single Unicode character 2 bytes 4 Short Used to store smaller range of numeric data 2 bytes 5 Integer Used to store numeric data 4 bytes 8 Object Used to store data of any type 4 bytes 9 Single Used to store single precision floating-point values 4 bytes 10 Double Used to store double precision floating-point values 8 bytes 11 Date Used to store date and time information 8 bytes 12 Long Used to store large numeric data 8 bytes 14 Decimal Used to store very large floating-point values 16 bytes 15 String Used to store alphanumeric data 2 bytes (ii) Variable and Constants Variables A variable is an entity that has a value and this value varies or changes during the program execution. In other words a variable is an address of a block of memory that stores information. A variable is nothing but a name given to a storage area that our programs can manipulate. Constants These are similar to variables, except that they store fixed values. (iii) Variable Declaration in VB.Net The Dim statement is used for variable declaration and storage allocation for one or more variables. The Dim statement is used at module, class, structure, procedure or block level. Syntax for variable declaration in VB.Net is:

45 45 [ < attributelist> ] [ accessmodifier ] [[ Shared ] [ Shadows ] [ Static ]] [ ReadOnly ] Dim [ WithEvents ] variablelist Where, attributelist is a list of attributes that apply to the variable. It is Optional. accessmodifier defines the access levels of the variables, it has values as - Public, Protected, Friend, Protected Friend and Private. It is Optional. Shared declares a shared variable, which is not associated with any specific instance of a class or structure, rather available to all the instances of the class or structure. It is Optional. Shadows indicate that the variable re-declares and hides an identically named element, or set of overloaded elements, in a base class. It is Optional. Static indicates that the variable will retain its value, even when the after termination of the procedure in which it is declared. It is Optional. ReadOnly means the variable can be read, but not written. It is Optional. WithEvents specifies that the variable is used to respond to events raised by the instance assigned to the variable. It is Optional. New: optional. It creates a new instance of the class when the Dim statement runs. Data type: Required if Option Strict is On. It specifies the data type of the variable. initializer: Optional if New is not specified. Expression that is evaluated and assigned to the variable when it is created. Some valid variable declarations along with their definition are shown here: Dim StudentID As Integer Dim StudentName As String Dim Salary As Double Dim count1, count2 As Integer Dim status As Boolean Dim exitbutton As New System.Windows.Forms.Button Dim lasttime, nexttime As Date Variablelist provides the list of variables declared. Each variable in the variable list has the following syntax and parts:

46 46 variablename[ ( [ boundslist ] ) ] [ As [ New ] datatype ] [ = initializer ] Where, variablename: is the name of the variable boundslist: optional. It provides list of bounds of each dimension of an array variable. (iv) Variable Initialization in VB.Net Variables are initialized (assigned a value) with an equal sign followed by a constant expression. The general form of initialization is: variable_name = value; for example, Dim pi As Double pi = You can initialize a variable at the time of declaration as follows: Dim StudentID As Integer = 100 Dim StudentName As String = "Bill Smith" (v) Rules of Naming Variable (naming conventions) There are certain rules or naming conventions to be followed as given below: The name must begin with a letter. The only symbols allowed in naming convention are letters, numbers and underscore. Even spaces are not allowed. The maximum length of the name of variable is 40 characters. Reserved words like Sub etc cannot be used as name of variable. Variable name should be meaningful and easy to understand for proper documentation of the application.

47 47 (vi) Operators An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Visual Basic.NET supports the following type of operators. Arithmetic Operators Comparison Operators Logical/Bitwise Operators Assignment Operators Arithmetic Operators Arithmetic operators perform mathematical calculations. The arithmetic operators supported by Visual Basic.NET are: Suppose variable X holds 5 and variable Y holds 2, then: Operator Description Example + Adds two operands X + Y will give 7 - Subtracts second operand from the first X - Y will give 3 * Multiplies both operands X*Y will give 7 / Divides one operand by another and returns a floating point result \ Divides one operand by another and returns an integer result X / Y will give 2.5 X \ Y will give 2 ^ Raises one operand to the power of another X^Y will give 25 MOD Modulus Operator and remainder of after an integer division X MOD Y will give 1 Comparison Operators Comparison operators are used to compare expressions. In Visual Basic.NET, following operators can be used to compare expressions:

48 48 Relational Operators Is Operators Like Operators Relational Operators Relational Operators are used to compare two numerical values and return a Boolean value as a result. Following table shows all the comparison operators supported by VB.Net. Assume variable A holds 10 and variable B holds 20, then: Operator Description Example = Checks if the values of two operands are equal or not; if yes, then condition becomes true. <> Checks if the values of two operands are equal or not; if values are not equal, then condition becomes true. > Checks if the value of left operand is greater than the value of right operand; if yes, then condition becomes true. < Checks if the value of left operand is less than the value of right operand; if yes, then condition becomes true. >= Checks if the value of left operand is greater than or equal to the value of right operand; if yes, then condition becomes true. <= Checks if the value of left operand is less than or equal to the value of right operand; if yes, then condition becomes true. (A = B) is not true. (A <> B) is true. (A > B) is not true. (A < B) is true. (A >= B) is not true. (A <= B) is true. Consider the following statement. Dim Result as Boolean Result=50>60 Returns False

49 49 Result=62=62 Result=14<>24 Returns True Returns True The above statement compares two numerical values and returns a Boolean value as a result. Is Operator It also compares two object reference variables and determines if two object references refer to different objects. If object1 and object2 both refer to the exact same object instance, result is True; otherwise, result is False. Consider the following statements: Dim object1 As String = "" Dim object2 As Form = Nothing Dim result As Boolean result = object1 Is object2 MessageBox.Show(result) Returns False Like Operator The Like operator is used to compare strings and return a Boolean value as the result. The following example demonstrates the use of the Like operator. Dim Result as Boolean Result= VB Like VB Result= VB Like vb Returns True Returns False The above example compares two strings and stores the result as a Boolean value in a variable called Result. Logical/Bitwise Operators Logical operators enable you to perform logical operations. Visual Basic.NET provides the following logical operators: AND Operator OR Operator

50 50 NOT Operator XOR Operator AndAlso Operator OrElse Operator AND Operator The AND operator is used to perform the AND logical operation on expressions. The AND operator returns a True only when all expressions return True. Consider the following statement. Dim Result As Boolean Dim X As Integer=40 Dim Y As Integer=30 Dim Z As Integer=20 Result=X>Y AND Y>Z Returns True Result=Y>X AND Y>Z Returns False OR Operator The OR operator is used to perform the OR logical operation on expressions. If one of the expressions returns True, the OR operator returns True. Dim Result as Boolean Dim X As Integer=40 Dim Y As Integer=30 Dim Z As Integer=20 Result= X>Y OR Y>Z Returns True NOT Operator

51 51 The NOT operator is used to perform the NOT logical expression on operands. The operands may or may not be expressions. Whatever the value of the expression, the NOT operator negates it and return the opposite value. If the expression returns True, the NOT operator makes it False and vice versa. Dim Result as Boolean Dim X As Integer=40 Dim Y As Integer=30 Result=NOT(X>Y) Returns False XOR Operator The XOR operator performs the logical exclusion on two expressions. It returns True if either test expression but not both is True. Dim Result as Boolean Dim X As Integer=40 Dim Y As Integer=30 Dim Z As Integer=20 Result=X>Y XOR Y>Z Returns False In the above statement, the first test expression returns False because both the conditions X>Y AND Y>Z return True. AndAlso Operator AndAlso operator is a short circuited AND operator. The AndAlso operator is used to perform logical expressions. If the first expression is false, the second expression is not tested. Dim X As integer=40 Dim Y As Integer=30 Dim Z As Integer=20 Dim Result As Boolean Result=Y>X AndAlso Z>X Returns False

52 52 In the above statement second test expression is not evaluated because the first test expression evaluates to False. OrElse Operator OrElse Operator is a short circuited OR operator. The OrElse operator is used to perform logical operations on Boolean expressions. If the first test expression is True second test expression is not tested. Dim X As integer=15 Dim Y As Integer=10 Dim Z As Integer=5 Dim Result As Boolean Result=X>Y OrElse Y>Z Returns True Assignment Operator Assignment operator is used to perform arithmetic operations while assigning a value to a variable. The "=" operator is used for assignment. The operator also serves as a comparison operator For example, we add two variables with the + addition operator and store the result in a third variable with the = assignment operator. Operator Description Example = Simple assignment operator, Assigns values from right side operands to left side operand += Add AND assignment operator, It adds right operand to the left operand and assigns the result to left operand -= Subtract AND assignment operator, It subtracts right operand from the left operand and assigns the result to left operand *= Multiply AND assignment operator, It multiplies right operand with the left operand and assigns the result to left operand /= Divide AND assignment operator, It divides left operand with the right operand and assigns the result C = A + B will assign value of A + B into C C += A is equivalent to C = C + A C -= A is equivalent to C = C - A C *= A is equivalent to C = C * A C /= A is equivalent to C = C

53 53 to left operand (floating point division) \= Divide AND assignment operator, It divides left operand with the right operand and assigns the result to left operand (Integer division) ^= Exponentiation and assignment operator. It raises the left operand to the power of the right operand and assigns the result to left operand / A C \= A is equivalent to C = C \A C^=A is equivalent to C = C ^ A When = operator is used for comparison for example: If x = 4 Then MessageBox.Show("x is four.") End If (vii) Branching Statement/Decision Making Statement/Conditional Statement Decision making statements in VB.NET are used to control the flow of a program by checking one or more conditions. These conditions may be a simple Boolean value, a value entered by the user, or a value returned from a function. The branching statements are: 1. If Statement If.Then If.Then Else If.Then.ElseIf Statement Nested If Statements 2. Select Case Statement 1. If Statement: It allows you to test whether statements are true or false and then execute statement block. If Then Statement

54 54 It is the simplest form of control statement, frequently used in decision making and changing the control flow of the program execution. This statement is used to test a condition and execute a statement block if the condition is true. If it is false, the statement which is next to the if then structure is executed. Syntax: If <condition> Then Statement Block End If Where, condition is a Boolean or relational condition and Statement(s) is a simple or compound statement. Example: Dim mark as integer If mark>40 then Msgbox ( Pass ) End if If Then Else This statement is used to test a condition and execute a statement block if the condition is true and execute another statement block if it is false. Syntax: If <condition> Then Statement block1 Else Statement block2 End If Example: Dim no as integer no=textbox1.text If no MOD 2=0 Then

55 55 Msgbox( EVEN NUMBER ) Else Msgbox( ODD NUMBER ) End If If ElseIf Then Statement If ElseIf Then statement is used to conditionally execute code based on more than one test condition or statement. If the condition provided in the If statement evaluates to true, the code in the block is executed. If condition is false, the following ElseIf statement is evaluated, if any are true, the corresponding statement block is executed. If there are no If or ElseIf statement are true, then the statement block in the else will be executed. Syntax: If <condition> then Statement block 1 ElseIf <condition> then Statement block 2 ElseIf <condition> then Statement block Else Statement block else End If Example: Dim x As Integer=5 Dim y As Integer=10

56 56 If x = y Then Msgbox( x is equal to ys ) ElseIf x > y Then Msgbox( x is greater than y ) Else Msgbox( y is greater than y ) End If Nested If Statement This statement is used to check multiple conditions, which means you can use one If or ElseIf statement inside another If ElseIf statement(s). Syntax: If <Condition> Then End If Else If <Condition> Then <Statement block> Else <Statement block> <Statement block> End if Example: Dim a,b,c as Integer a=10 b=20 c=30

57 57 If a>b Then If a>c Then MsgBox( a is greatest ) Else Msgbox( c is greatest ) End If Else If b>c Then MsgBox( b is greatest ) Else Msgbox( c is greatest ) End If End If 2. Select Case Statement The Select Case statement enables you to conditionally execute a series of statement groups based on the value of a test expression, which can either be a single variable or a complex expression. The Select Case statement test the value of a given variable or expression against a list of case values and when a match is found, a block of statement associated with that case is executed. Syntax: Select Case expression Case value1 Block of one or more VB statements Case value2 Block of one or more VB Statements Case value3

58 58 Block of one or more VB statements Case value4.. Case Else Block of one or more VB Statements End Select Example 1: Dim grade As String grade=txtgrade.text Select Case grade Case "A+" result.text="excellence" Case "A" result.text="good" Case "B" result.text="average " Case "C" result.text="pass" Case Else result.text="fail" End Select Example 2: Dim mark As Single mark =TextBox1.Text

59 59 Select Case mark Case Is >= 85 comment.text = "Excellence" Case Is >= 70 comment.text = "Good" Case Is >= 60 comment.text = "Above Average" Case Is >= 50 comment.text = "Average" Case Else comment.text = "Need to work harder" End Select End Sub (viii) Looping Statement There can be a situation in programming to repeat a task for several times until a condition is fulfilled. VB.NET allows a block of statements to be repeated many times. This is generally called looping. Looping allow you to repeat an action for a number of times or until a specified condition is reached. Visual Basic.NET provides the following types of loop statements. 1. Do Loop 2. While Loop 3. For Next Loop 4. For Each Next Loop 5. Do Until Loop 6. Do Loop Until Loop Do While Statement

60 60 A Do While Statement runs until the condition becomes false. Its condition is checked after each iteration of the loop. The Do Loop construction allows you to test a condition at either the beginning or the end of a loop structure. It could be terminated at any time with the Exit Do statement. There are two format of Do While Loop a) Do While <condition> Statement Block Loop b) Do Statement Block Loop While <condition> In Second format of Do While Loop Statement executes at least once, irrespective of whether the condition is True or False and then the condition is evaluated. Example: Print 1 to 100 Dim i as Integer=1 Do while i<=100 Listbox1.Items.Add(i) i=i+1 Loop In Other format this program can be written as:s Dim i as Integer=1 Do Listbox1.Items.Add(i) i=i+1 Loop while i<=100 While Statement

61 61 While Statement executes a statement block iteratively (repeatedly) until the condition becomes false. It could be terminated at any time with the Exit While statement. Syntax: While <condition> Statement Block End While Example: Display Odd Number from Dim I as Integer i=1 While i<=100 Listbox1.Items.Add(i) I=i+2 End While For Statement/For Next Statement The For Next Statement executes a Statement Block for a fixed number of times. The For loop is the most well-known looping statement and useful in many programs. The syntax of For loop is: For <variable_name>=<start> To <End> Step <value> Statement Block Next <variable_name> In the above syntax, <variable_name> is the name of variable, Start is the initial value that the <variable_name> should take, <End> is the final value that the <variable_name> should take and the value is the increment or decrement. It could be terminated at any time with the Exit For statement. Example: Program to display even numbers between 1 and 100 Dim i as integer For i=1 to 100 Step 1

62 62 If i MOD 2=0 then Listbox1.Items.Add(i) Next i For Each Statement/For Each Next Statement For Each Next statement is similar to the For Next statement. The For Each Next statement executes a statement block for a fixed number of times and enables you to traverse through a collection, such as array or ListBox Items. The syntax of For Each next Statement is: For Each <variable_name> In <name of the collection> Statement Block Next In the above syntax, <variable_name> is the name of the variable and <name of the collection> is the name of the collection through which you access each element. Example 1: Dim arr() as Integer={1,2,3,4,5} Dim i as Integer For Each i in arr MsgBox(i) Next Example 2: ListBox1.Items.Add( Keyboard ) ListBox1.Items.Add( Mouse ) ListBox1.Items.Add( Printer ) For Each Item in ListBox1.Items MsgBox(Item) Next

63 63 Do Until Loop Statement In this loop, the statement block is repeatedly executed as long as the condition evaluates to false. The condition is evaluated at the beginning of every iteration. When the condition evaluates to true the control is transferred to the next line of code following the statement. Syntax: Do Until <condition> Statement Block Loop Example: Calculate Factorial of any number Dim no, i, fact As Integer i = 1 fact = 1 no = TextBox1.Text Do Until i > no fact = fact * i i = i + 1 Loop MsgBox(fact) Do Loop Until Statement In Do Loop Until Statement; the condition is evaluated except the first iteration. It executes statement block repeatedly until the condition becomes True. Do Loop Until Statement executes at least once, irrespective of whether the condition is True or False and then the condition is evaluated. Example: Display first 100 Natural Numbers Dim i as integer i=1 Do

64 64 ListBox1.Items.Add(i) I=i+1 Loop Until i>100 Procedure A procedure is a block of program code that performs a specific task. Procedures allow you to break your programs into discrete logical units, each of which you can debug more easily than an entire program without procedures. Procedures used in one program can act as building blocks for other programs, usually with little or no modification. There are three types of procedures used in Visual Basic.Net: Sub procedures/subroutine Function procedures Property procedures Sub Procedure: The Sub procedure performs a task and then returns control to the calling code, but it does not return a value to the calling code. A subroutine always begins with the Sub statement and always ends with the End Sub statement. A subroutine may or may not be an event procedure. Types of Sub Procedure: General or Non-event procedure Event procedure or Event handling procedure General Sub Procedure: A general procedure is used to accomplish a specific task. It must be deliberately invoked by the program. Sub GenlSubProc (Arguments) Statement Block End Sub Using General Sub procedures can help divide a complex application into more manageable units of code. This is used for readability and reusability.

65 65 Event Procedure: Event-handling procedures are Sub procedures that execute in response to an event raised by user action or by an occurrence in a program. Visual Basic uses a standard naming convention for event handlers that combine the name of the event sender, an underscore, and the name of the event. For example, the Click event of a button named button1 would be named Sub button1_click. Private Sub Object_Event(args) Handles Object.Event Statement block End Sub Example: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click StatementCompletedEventArgs() End Sub Function Procedure A function procedure always begins with the Function statement and ends with the End function statement. A function is the same in every way as a subroutine except that the function returns a value to the calling code. To return a value to the calling function or procedure we use a keyword return. [Modifiers] Function FunctionName [(ParameterList)] As ReturnType [Statements] End Function Example: Function Addem(ByVal int1 As Integer, ByVal int2 As Integer) As Integer Return int1 + int2 End Function Property Procedures A Property procedure returns and assigns values of properties on objects or modules. These procedures are declared with a keyword Property and are generally used to expose the properties of a class. Here, we define the appropriate getter and setter blocks to expose the property as required. Visual Basic provides for the following property procedures: A Get procedure returns the value of a property. It is called when you access the property in an expression. A Set procedure sets a property to a value, including an object reference. It is called when you assign a value to the property.

66 66 You usually define property procedures in pairs, using the Get and Set statements, but you can define either procedure alone if the property is read-only (Get Statement) or write-only (Set Statement). You can define properties in classes, structures, and modules. Properties are Public by default, which means you can call them from anywhere in your application that can access the property's container. Example: Public Class Form1 Dim age As Integer Private Property Y() As Integer Get Return age End Get Set(ByVal Value As Integer) age = Value MsgBox("Age set") End Set End Property Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E_ventArgs) Handles Bu tton1.click If TextBox1.Text = "" Then MsgBox("Please enter your age") Else End If End Sub Try Y = TextBox1.Text Catch ex As Exception MsgBox(ex.Message) End Try TextBox1.Clear()

67 67 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox("Your age is: " & Y) End Sub End Class Built-In Function The built-in functions are predefined functions that is available in VB.NET. The built-in functions in Visual Basic are classified into the following categories according to their capabilities: Input and output, file handling, data type inspection, data type conversion, string handling, formatting, mathematical, date and time, financial, drawing, and miscellaneous. For example, MsgBox() and InputBox() are built-in functions. Visual Basic offers various built-in functions. According to their capabilities, these functions can be classified into the following categories: 1. Input and Output functions: InputBox() is an input function. It is used to get a string of text from the user. MsgBox() is an output function. It displays a message in a dialog box, waits for the user to click a button, and then return s an integer indicating which button the user clicked. The MsgBox Function The MsgBox function displays a message in a dialog box, waits for the user to click a button, and returns an Integer indicating which button the user clicked. Syntax: MsgBox(prompt[, buttons] [, title]) Or

68 68 IntegerVariable = MsgBox(prompt[, buttons] [, title]) The MsgBox function syntax has these parts: Part Description prompt String expression displayed as the message in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. It is required to specify. buttons Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If omitted, the default value for buttons is 0 (which causes only an OK button to be displayed with no icon). It is optional. title String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar. It is optional. You can find the possible constants to use for the Buttons arguments Constant Value Description OKOnly 0 Shows OK button only. OKCancel 1 Shows OK and Cancel buttons. AbortRetryIgnore 2 Shows Abort, Retry, and Ignore buttons. YesNoCancel 3 Shows Yes, No, and Cancel buttons. YesNo 4 Shows Yes and No buttons. RetryCancel 5 Shows Retry and Cancel buttons. Critical 16 Shows Critical Message Icon. Question 32 Shows Warning Query Icon. Exclamation 48 Shows Warning Message icon. Information 64 Shows Information Message icon. DefaultButton1 0 First button is default. DefaultButton2 256 Second button is default.

69 69 DefaultButton3 512 Third button is default. ApplicationModal 0 Application modal which means the user must respond to the message box before continuing work in the current application. SystemModal 4096 System modal, which means all applications are suspended until the user responds to the message box. MsgBoxSetForeground Specifies the message box window as the foreground window. MsgboxRight Text will be right-aligned. MsgBoxRtlReading Specifies text should appear as right-to-left on RTL systems such as Hebrew and Arabic. Example: Private Sub Button1_Click( ByVal Sender As System.Object, ByVal e as System.EventArgs) Handles Button1.Click Dim Result As Integer Result=MsgBox( This is a message box, MsgBoxStyle.OkCancel+MsgBoxStyle.Information+MsgBoxStyle.SystemModel, Example of MsgBox ) If(Result=MsgBoxResult.OK) Then TextBox1.Text= You Clicked Ok End if End Sub InputBox Function Displays a prompt in a dialog box, waits for the user to input text or click a button, and then returns a string containing the contents of the text box.

70 70 Public Function InputBox(ByVal Prompt As String, _ Optional ByVal Title As String = "", _ Optional ByVal DefaultResponse As String = "", _ Optional ByVal Xpos As Integer = -1, _ Optional ByVal YPos As Integer = -1 _ ) As String Parameters Prompt Required String expression displayed as the message in the dialog box. The maximum length of Prompt is approximately 1024 characters, depending on the width of the characters used. If Prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a line feed character (Chr(10)), or a carriage return/line feed combination (Chr(13) & Chr(10)) between each line. Title Optional. String expression displayed in the title bar of the dialog box. If you omit Title, the application name is placed in the title bar. DefaultResponse Optional. String expression displayed in the text box as the default response if no other input is provided. If you omit DefaultResponse, the displayed text box is empty. XPos Optional. Numeric expression that specifies, in pixels, the distance of the left edge of the dialog box from the left edge of the screen. If you omit XPos and YPos, the dialog box is centered on the screen.

71 71 YPos Optional. Numeric expression that specifies, in pixels, the distance of the upper edge of the dialog box from the top of the screen. If you omit XPos and YPos, the dialog box is centered on the screen. 2. Mathematical and Numerical functions: These functions are used in mathematical and numerical calculations. All the mathematical and numerical functions in VB.Net are implemented as methods of the Math Class. For example, the method Sqrt( ) can be used to compute the square root of an argument. In order to use any method in the Math class, type the Imports System.Math statement at the top of the code window. If you omit this statement then you are required to prefix the method name by class name, as shown below: Example: Dim a as double=system.math.sqrt(25) There are number of methods in Math class listed below. Every method accepts a literal(or expression) as an input, and returns a numeric value. Abs(): Returns the absolute value of specified number. Example: Dim no as Double no=system.math.abs(25.15) returns no=system.math.abs(-25.15) returns Atan( ): Returns the arc tangent (inverse tangent) of an argument, in radians. Cos( ): Returns the cosine of an argument (argument in radians). Sin( ): Returns the sine of an argument (argument in radians). Tan( ): Returns the tangent of an argument (argument in radians). Sqrt( ): Returns the tangent of an argument (argument in radians). Sqrt( ): Returns the square root of an argument. Example:

72 72 Dim no as Double no=system.math.sqrt(25) returns 5 Round( ): Returns the rounded value of an argument. Pow( ): Accepts two numeric arguments and returns the first number raised to the power specified by the second argument. Example: Dim no as Double no=system.math.pow(5,3) returns 125 Min( ): This function returns the smaller of two numbers specified. Example: Dim no as double no=system.math.min(25.5,20) returns 20 Max( ): This function returns the smaller of two numbers specified. Example: Dim no as double no=system.math.max(25.5,20) returns 25.5 Exp( ): Returns e to the power of x where e is the base of natural logarithm (e= ) and x is an argument. Log( ): Returns the natural logarithm of an argument. Example: Dim no as double no=log(2) returns String handling functions: A number of string handling functions are available in VB.Net. These functions are used to perform operations on string. For example, the function Len( ) returns the length of a string (string is an argument). Example:

73 73 Asc(str): Function Asc(str) returns the ASCII code of the first character in the string str. Dim no as integer no=asc( Dhiraj ) Now the value of no is 68, the ASCII code of D Chr(no): Function Chr(no) returns the character with ASCII code no. Example: Dim ch as Char Ch=Chr(68) returns result D UCase(str): Function UCase(str) converts all the lowercase characters in a string in uppercase cha racters. Example: Dim Lstr as String Dim str as String= nutan Lstr= LCase(str) returns NUTAN LCase(str): Function LCase(str) converts all the uppercase characters in a string in lowercase characters. Example: Dim Lstr as String Dim str as String= Nutan Lstr= LCase(str) returns nutan Left(str, n): It returns first n characters from a string str from the left.

74 74 Example: Dim str as string= Sarojini Dim newstr as string Newstr=Microsoft.VisualBasic.Left(str,5) returns Saroj as output Right(str, n): It returns last n characters from a string str from the right. Example: Dim str as string= Sarojini Dim newstr as string Newstr= Microsoft.VisualBasic.Right(str,5) returns ojini as output Mid(str, n, m): Function Mid(str, n, m) returns the string that consist of m characters from the string str, starting from the n th character. The argument m is optional. Example: Dim str, strresult as string str= Dhiraj strresult=mid(str,4,3) returns raj as output If you omit last argument m then it returns characters from the string str, starting from nth character to the end of the string str. Example: Dim str, strresult as string str= Dhiraj strresult=mid(str,4)

75 75 returns raj as output Len(str): It returns length of string str or number of characters in a string. Example: Dim no as Integer no=len( Dhiraj ) returns 6 as output LTrim(str): It removes leading spaces (if any) from the string str. In other words, it removes spaces from left from the string str. Example: Dim strresult as string strresult =LTrim( Nutan ) returns Nutan as output Rtrim(str): It removes trailing spaces (if any) from the string str. In other words, it removes spaces from right from the string str. Example: Dim strresult as string strresult =RTrim( Nutan ) returns Nutan as output Trim(str): It removes leading and trailing spaces (if any) from the string str. Example: Dim strresult as string strresult =Trim( Nutan ) returns Nutan as output Val(str): It converts the string str into number and returns that number. Example:

76 76 Dim no as integer no=val( 20 ) returns 20 as output Str(no): It converts the number no into string and returns that string. Example: Dim strresult as string strresult =Str(20) returns 20 as output StrReverse(str): Function strreverse(str) returns the string after reversing it. Dim strresult as string strresult =StrReverse( Nutan ) returns natun as output 4. Date and Time handling functions: A number of date and time handling functions are available in VB.Net. These functions are used to perform operations on Date and Time data. These functions are very important for banks and other similar organizations, where computation of interest on loans and deposits is calculated. Date and Time functions are following: Now( ): This function returns a date value containing the current date and time according to your system setting. Dim dt as Date dt=now( ) returns 11/20/2013 7:30:55 AM Today( ): This function returns a date value containing the current date only. Dim dt as Date dt=today( ) returns 11/20/2013

77 77 TimeOfDay( ): This function returns a date value containing only current time only. Dim dt as Date dt= TimeOfday( ) returns 7:30:55 AM DateSerial(intY, intm, intd): Function DateSerial(intY, intm, intd) returns the date in which the year is inty, the month is intm, and the day is intd. Example: Dim strresult=dateserial(2013,11,22) Now the value of strresult is 11/22/2013 DateAdd(strInterval, intn, dt): It returns a date value containing a date and time value to which a specified time interval has been added. Example: Dim dt as Date dt=dateadd( d, 5, 11/22/2013 ) returns 11/27/2013 dt=dateadd( m, 5, 11/22/2013 ) returns 4/22/2014 dt=dateadd( yyyy, 5, 11/22/2013 ) returns 4/22/2018 DateDiff(strInterval, dt1, dt2): Function DateDiff(strInterval, dt1, dt2) returns the difference between the dates dt1 and dt2, according to the criteria specified by the strinterval. Example: Dim n as integer Dim dt1, dt2 as date

78 78 dt1= 11/22/2013 dt2= 12/22/2014 n= DateDiff( d, dt1,dt2) returns 30 as output n= DateDiff( m, dt1,dt2) returns 1 as output n= DateDiff( yyyy, dt1,dt2) returns 0 as output DatePart(strInerval, dt): Function DatePart(strInerval, dt) returns the part of datedt according to the criteria specified by strinterval. Example: Dim n as integer N=DatePart( d, 11/22/2013 ) N=DatePart( m, 11/22/2013 ) N=DatePart( d, 11/22/2013 ) returns 22 as output returns 11 as output returns 2013 as output Year(dt): Function Year(dt) returns the year of the date dt. Example: Dim dt as date dt= 11/22/2013 Dim n as integer=year(dt) returns 2013 as output Month(dt): Function Month(dt) returns the month of the date dt. Example: Dim dt as date dt= 11/22/2013 Dim n as integer=month(dt) returns 11 as output

79 79 Day(dt): Function Day(dt) returns the day of the date dt. Example: Dim dt as date dt= 11/22/2013 Dim n as integer=microsoft.visualbasic.day(dt) returns 11 as output Hour( ): It returns hour only from a given time. If you feed the function Now as argument to this function, it return hours in a current time. Dim n as Integer n=hour(now) returns 4 if Now( ) returns 11/22/2013 4:20:15 AM Minute( ): It returns minute only from a given time. If you feed the function Now as argument to this function, it return minutes in a current time. Dim n as Integer n=minute(now) returns 20 if Now( ) returns 11/22/2013 4:20:15 AM Second( ): It returns second only from a given time. If you feed the function Now as argument to this function, it return seconds in a current time. Dim n as Integer n=second(now) returns 15 if Now( ) returns 11/22/2013 4:20:15 AM TimeSerial(intH, intm, ints): Function TimeSerial(intH, intm, ints) returns the time as Time format (h:m:s). Example: Dim str as string

80 80 str=timeserial(10,25,30) returns value 10:25:30 PM 5. Data Type Inspection functions: These functions are used for inspecting the data type of a given expression. For example, function IsNumeric( ) returns True if the argument evaluates to a number; otherwise, it return False. Some of the data type inspection functions are following: IsArray( ): Function IsArray( ) returns the value True if the argument is array. Otherwise, it returns the value False. Example: Dim n as Integer Dim x(10) as Integer Dim br as Bollean br=isarray(n) br=isarray(x) returns value False returns value True IsDate( ): Function IsDate( ) returns the value True if the argument is date. Otherwise, it returns the value False. Example: Dim n as Integer Dim dt as Date Dim br as Bollean br=isdate(n) br=isdate(dt) returns value False returns value True IsDBNull( ): Function IsDBNull( ) returns the value True if an argument is DBNull. DBNull refers to invalid value and it represents missing or nonexistent data.

81 81 IsNothing( ): Function IsNothing( ) returns the value True if the value of an argument is nothing. Otherwise, it returns the value False. Example: Dim obj as object Dim br as Result obj=nothing br=isnothing(obj) returns True obj=new Point(5,10) br=isnothing(obj) returns False IsNumeric( ): Function IsNumeric( ) returns the value True if an argument is numeric. Otherwise, it returns the value False. Example: Dim n as integer=10 Dim str as string= Nutan Dim br as Boolean br=isnumeric(n) br=isnumeric(str) returns True returns False IsReference( ): Function IsReference( ) returns the value True if an argument is an object variable. Otherwise, it returns the value False. Dim str as String Dim n as Integer Dim bresult as Boolean bresult= IsReference(str) bresult=isreference(n) returns True returns False TypeName( ): The TypeName( ) function returns the name of the data type of an argument.

82 82 Dim n as Integer Dim dt as date Dim str as String str=typename(n) str=typename(dt) returns Integer returns Date 6. Data Type Conversion Functions: Data Type Conversion Functions are used to convert one data type value to another data type. Every function except CType( ) accepts one valid argument. CBool( ): Function CBool( ) converts the argument(expression) to Boolean type. If an expression evaluates to a nonzero value, CBool returns the value True. Otherwise, it returns the value False. Example: Dim n as Integer=10 Dim m as Integer=0 Dim bresult as Boolean bresult=cbool(n) bresult=cbool(m) returns True returns False CByte( ): Function CByte( ) converts the argument (expression) to Byte type. Example: Dim b as Byte b=cbyte(10.25) returns 10 CChar( ): Function CChar( ) converts the argument (expression) to Char data type.

83 83 Generally, a string is argument to this function and the first letter of a string is converted to Char type. Example: Dim ch as Char ch=cchar( Dhiraj ) returns D CDate( ): Function CDate( ) converts the argument (string) to Date. A string argument must contain the valid format of date or time. Example: Dim dt as Date dt=cdate( 12/22/2013 ) dt=cdate( 08:25:20 AM ) returns 12/22/2013 as date type returns 08:25:20 AM as date type CDbl( ): Function CDbl( ) converts the argument to Double type. Example: Dim dbl as Double dbl=cdbl(10) returns 10 as Double type CDec( ): Function CDec( ) converts the argument to Decimal type. Example: Dim dec as Decimal Dec=CDec( ) returns as Decimal type CInt( ): Function CInt( ) converts the argument to Integer type. If the argument is fractional number, then it is rounded to the nearest integer. Example: Dim n as Integer n=cint( 20 ) returns 20 as Integer Type

84 84 n=cint(20.75) returns 21 as Integer type CLng( ): Function CLng( ) converts the argument to Long type. If the argument is fractional number, then it is rounded to the nearest integer. Example: Dim n as integer n=clng(15.25) n=clng(15.75) returns 15 as Long type returns 16 as Long type CObj( ): Function CObj( ) converts the argument to Object type. Example: Dim dbl as Double Dbl=12.25 dbl=cobj(dbl) returns as Object type CShort( ): Function CShort( ) converts the argument to Short type. Example: Dim n as Integer Dim m as Short n=25 m=cshort(n) returns 25 as Short type CSng( ): Function CSng( ) converts the argument to Single type. Example: Dim dbl as Double Dim sng as Single

85 85 dbl= sng=csng(dbl) returns as Single type CStr( ): Function CStr( ) converts the argument to String type. Example: Dim n as Integer=25 Dim str as String str=cstr(25) returns 25 as String type CType( ): Function CType( ) converts the first argument to data type specified in the second argument. Example: Dim n as Integer=25 Dim str as String str=ctype(n, String) returns 25 as Integer type 7. Financial functions: These functions are used in financial computations. 8. Miscellaneous functions: These are the functions which don t fit elsewhere. For example the function Rnd( ) and Beep( ) belong to this category. Function Rnd( ) computes a random number and function Beep( ) produces the beeping sound. Array An array stores a fixed-size sequential collection of elements of the same type. An array is a collection of variables or values of the same type. In simple words an array is a list of variables with the same data type and name.

86 86 For example, if we need to enter one hundred names, it is difficult to declare 100 different variables; this is a waste of time and efforts. So, instead of declaring one hundred different variables, we need to declare only one array. We differentiate each item in the array by using subscript, the index value of each item, for example name(0), name(1), name(2), name(3)...etc. The elements in an array can be stored and accessed by using the index of the array. Example 1: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim a(2) As Integer a(0) = 5 a(1) = 10 a(2) = 15 For Each element As Integer In array Listbox1.Items.Add(element) Next End Sub End Class Example 2: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer Dim week(6) As String week(0) = "Sunday" week(1) = "Monday" week(2) = "Tuesday" week(3) = "Wednesday" week(4) = "Thursday" week(5) = "Friday"

87 87 week(6) = "Saturday" For i = 0 To week.length - 1 MsgBox(week(i)) Next End Sub End Class Declaring an Arrays in VB.Net To declare an array in VB.Net, you use the Dim statement. For example, Dim intdata(30) as Integer Dim strdata(20) As String Dim twodarray(10, 20) As Integer Dim ranges(10, 100) ' an array of 31 integer values ' an array of 21 strings 'a two dimensional array of integers 'a two dimensional array You can also initialize the array elements while declaring the array. For example, Dim intdata() As Integer = {12, 16, 20, 24, 28, 32} Dim inames() As String = {"Keyboard", "Mouse", "Scanner", "Joystick", "Light Pen } Dim miscdata() As Object = {"Hello World", 12d, 16ui, "A"c} Types of Array 1. One Dimensional Array/Single Dimensional Array An array can be one dimensional or multidimensional. One dimensional array is like a list of items or a table that consists of one row of items or one column of items. One dimensional array stores all the elements of an array in a single row starting with index 0 until the end of the array. For example a(5) is a single dimensional array. Dim MyArray(10) As Integer Dim MyArray() As Integer={1,2,3,4,5} Dim myarray As Integer() = New Integer(10) {} Dim MyArray() As Integer = New Integer(4) { 1, 2, 3, 4, 5 } Example: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

88 88 Dim studentname(0 To 10) as String For num = 1 To 10 studentname(num) = InputBox("Enter the student name", "Enter Name") If studentname(num) <> "" Then ListBox1.Items.Add(studentName(num)) Else End End If Next End Sub End Class 2. Multi Dimensional Array VB.Net allows multidimensional arrays. Multidimensional array is an array in which each element acts as an array that are represented as row and columns. Multidimensional arrays are also called rectangular arrays. You can declare a 2-dimensional array of strings as: Dim twodstringarray(10, 20) As String or, a 3-dimensional array of Integer variables: Dim threedintarray(10, 10, 10) As Integer The following program demonstrates creating and using a 2-dimensional array: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click ' an array with 5 rows and 2 columns Dim a(,) As Integer = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 8}} Dim i, j As Integer ' output each array element's value ' For i = 0 To 4 For j = 0 To 1 ListBox1.Items.Add (a(i, j)) Next j Next i End Sub End Class

89 89 3. Dynamic Arrays Dynamic arrays are arrays that can be dimensioned and re-dimensioned as par the need of the program. You can declare a dynamic array using the ReDim statement. In other words Dynamic arrays are array that are declared using a Dim statement with blank parenthesis initially and are dynamically allocated dimensions using the Redim statement. Syntax for ReDim statement: ReDim [Preserve] arrayname(subscripts) Where, The Preserve keyword helps to preserve the data in an existing array, when you resize it. arrayname is the name of the array to re-dimension. subscripts specifies the new dimension. Example: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim marks() As Integer ReDim marks(2) marks(0) = 85 marks(1) = 75 marks(2) = 90 ReDim Preserve marks(10) marks(3) = 80 marks(4) = 76 marks(5) = 92 marks(6) = 99 marks(7) = 79 marks(8) = 75 For i = 0 To 10 ListBox1.Items.Add(i & vbtab & marks(i)) Next i End Sub End Class 4. Jagged Array A Jagged array is an array of arrays. The following code shows declaring a jagged array named scores of Integers: Dim scores As Integer()() = New Integer(5)(){} The following example illustrates using a jagged array:

90 90 Public class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim one() As Integer = {1, 2, 3} Dim two() As Integer = {3, 4, 5, 6, 7} Dim jag()() As Integer = {one, two} Dim i, j As Integer For i = 0 To jag.length - 1 For j = 0 To jag(i).length - 1 ListBox1.Items.Add((jag(i)(j))) Next j Next i End Sub End Class Example 2: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'a jagged array of 5 array of integers Dim a As Integer()() = New Integer(4)() {} a(0) = New Integer() {0, 0} a(1) = New Integer() {1, 2} a(2) = New Integer() {2, 4} a(3) = New Integer() {3, 6} a(4) = New Integer() {4, 8} Dim i, j As Integer ' output each array element's value For i = 0 To 4 For j = 0 To 1 ListBox1.Items.Add(i & j & vbtab & a(i)(j)) Next j Next i End Sub End Class

91 91 Unit-2 SDI and MDI Application SDI SDI stands for Single Document Interface. In this interface only a single document can be opened at a time. If you want to open a new document, you need to open a new instance of it. In single document interfaces (SDI) all windows are independent of each other. For example, Notepad is an example of SDI. MDI MDI stands for Multiple Document Interface. This interface can open multiple documents from one interface. MS Word is an example of MDI. You can open new documents Word, without closing documents that are already open. Difference between SDI and MDI SDI It stands for Single Document Interface. In this interface only a single document can be opened at a time. There is not parent window that means single window will be parent as well child window. We can work on single window. Switching from one application to another application is not possible. MDI It stands for Multiple Document Interface. This interface can open multiple documents from one interface. All child windows will remain in one parent window. We can work on multiple windows. Switching from one application to another application is possible.

92 92 In SDI inheritance is not possible. We have to prepare menu for every application. Example: Notepad, Internet Explorer 6 In MDI inheritance is possible. Single menu is shared with for every application that will reduce the work load of programmer as well as system will work perfectly. Example: MS Word, MS Excel, Adobe Photoshop Creation of SDI Forms The SDI features of Windows forms allow you to work with only one document at a time. A new application must be executed to open a new document or form. All the windows form you added are SDI forms. Consider an example in which you need to create an SDI application that contains two windows forms. One of the forms contains a button. When you click the button, a new form should be opened. The new form is an instance of the second form, and contains a label that displays the text, This is the Second Windows Form. When you clicked the Show Second Windows Form Button, second Windows Form is displayed.

93 93 Notice that the second windows form opened as individual form, and is not contained in the first windows form. You can open as many forms as required, but they will all be new and independent windows form. To create the SDI application, perform the following steps: 1. Open Microsoft Visual Studio Open File Menu then click on New Project. 3. Create a new Windows application. Add a button Button1 in the Windows form 4. Set the Text property of Button1 with value Show Second Windows Form 5. Set the Text property of Form1 with value First Windows Form 6. Click Project menu and then click Add Windows Form. Add New Item Dialog box appears as shown in figure:

94 94 7. In the Templates pane, click Windows Form and then click Add. A new form is added to the existing project. Change the text property of the form to Second Windows Form. 8. Add a Label control named Label1 to the second Windows Form and change the Text property to This is the Second Windows Form. 9. Double click the Button1 on Windows Form1. Add the following code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim secondwindow As New Form2 secondwindow.show() End Sub In code an object of Form2 is created and displayed using the Show method of Windows Form. Creation of Parent and Child MDI Form

95 95 The MDI feature of Windows form s allows you to open multiple documents in one window. You can open as many forms as required using the options in the menu bar. The Windows form containing the multiple documents is known as MDI Parent form. Each document contained in the Parent container is known as MDI Child. Consider an application that contains Parent and Child forms. The first Form has a menu bar containing a menu named File and Windows. The File menu should have two menu items, New and Exit. The Windows menu should have three menu items, Tiles Windows Horizontally, Tiles Windows Vertically and Cascade Windows. When you click File New, a new instance of MDI Child is created and displayed in MDI Parent form. You can open multiple instance of MDI Child. Click File Close to close the active MDI Windows form. When you click Windows Tile Windows Horizontally, all the child form should be arranged horizontally. Similarly Tile Windows Vertically and Cascade windows should be worked. To create the MDI Windows application, perform the following steps: 1. Open Microsoft Visual Studio Open File Menu then click on New Project 3. Create a new Windows application. Change the IsMdiContainer property of the Windows Form 1 to True. 4. Change the Text property of the Form 1 to Menu. 5. Add a MenuStrip control to the Form 1. Type the menu items for creating menus. 6. Shortcut key can be defined using the property ShortcutKeys of Menu Items.

96 96 7. After creating menu items write the code in the Click event of corresponding menu item of the MDI Parent Form. 8. Code for New Menu Item Public i As Integer Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click Dim child As New Form child.mdiparent = Me i = i + 1 End Sub child.text = "Child " + CStr(i) child.show() In above code, a new object of Form is created named child. The MDIParent property of child is set to MdiParent(Me). The Me keyword is used to refer to the MDI Parent itself. The child form is loaded using the Show( ) method of the Windows form.

97 97 Code for the Close Menu Item Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click If me.activemdichild Is Nothing Then Else Me.ActiveMdiChild.Close( ) End Sub In the above code, the mnuclose_click event handle handles the event when you click the Close menu item. The ActiveMdiChild property of the MDIParent Windows form is used to get the active MDI Child form. If there is any MDI child form, the function closes it using the Close method.

98 98 Code for the Menu Item named Tile Windows Horizontally Private Sub TileHorizontallyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileHorizontallyToolStripMenuItem.Click End Sub Me.LayoutMdi(MdiLayout.TileHorizontal) In the above code, LayoutMDI method arranges the MDI Child forms in MDI Parent Form. In this method we pass the value MdiLayout.TileHorizontal. It arranges all MDI Child forms in Horizontally in MDI Parent. Code for the Menu Item named Tile Windows Vertically

99 99 Private Sub TileVerticallyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileVerticallyToolStripMenuItem.Click End Sub Me.LayoutMdi(MdiLayout.TileVertical) In the above code, LayoutMDI method arranges the MDI Child forms in MDI Parent Form. In this method we pass the value MdiLayout.TileVertical. It arranges all MDI Child forms in vertically in MDI Parent. Code for the Menu Item named Cascade Windows Private Sub CasecadeWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CasecadeWindowToolStripMenuItem.Click End Sub Me.LayoutMdi(MdiLayout.Cascade) In the above code, LayoutMDI method arranges the MDI Child forms in MDI Parent Form.

100 100 In this method we pass the value MdiLayout.Cascade. It arranges all MDI Child forms in cascade manner in MDI Parent. Creating Menus at design time A menu prompts you to select from a list of options. When you use menus, there is no need to remember the command that has to be executed. Instead, all you have to do is to click the menu item and select an option that is presented to you. The code associated with the Click event of the menu item executes the required functionality. There are two types of menus provided in Visual Basic.NET. These are: 1. Menu items that appear in the menu bar at the top of the Windows form. This type of menu is available only to the Windows form control. 2. Menu items that appear as a pop-up when you right click the control. This pop-up menu is called context menu. The context menu must be attached to the control to be used.

101 101 Adding Menu items to the Menu Bar Menu items are used to provide a number of options. You can either click the menu itemsor use the keyboard to navigate through the items. A small line below a character in the menu item can be used to navigate the items using the keyboard called Access Key. You can also use the combination of Alt+.

102 102 Creating Menu at Runtime You can add a menu programmatically to a windows form in several steps: 1. Create a new public procedure named AddMenuAnd Items Public Sub AddMenuAndItems( ) code End Sub 2. Within that procedure, declare an instance of a MainMenu object named mnu Dim mnu as New MainMenu( ) 3. Set the Menu property of the form to the MainMenu instance you just created. This associates mnu as the menu for the form: Me. Menu=mnu 4. Within the procedure, create MenuItem objects to add to the MainMenu object s collection. Dim mnufile as new MenuItem( &File ) Dim mnunew as new MenuItem( &New ) 5. Since a MainMenu object starts with no menu items, the first menu item added becomes the menu heading, then add this menu item to the MainMenu object s mnu. mnu.menuitems.add(mnufile) 6. The following menu item is added to mnufile such as: mnufile.menuitems.add(mnunew) mnufile.menuitems.add(mnuclose)

103 We can specify shortcut key for menu items as follows: mnunew.shortcut = System.Windows.Forms.Shortcut.CtrlN The finished procedure should now read as follows: Public Sub AddMenuandItems() Dim mnu As New MainMenu() Me.Menu = mnu Dim mnufile As New MenuItem("&File") Dim mnunew As New MenuItem("&New") Dim mnuexit As New MenuItem("&Close") mnu.menuitems.add(mnufile) mnufile.menuitems.add(mnunew) mnufile.menuitems.add(mnuclose) mnunew.shortcut = System.Windows.Forms.Shortcut.CtrlN End Sub Add functionality to the Menu Items The purpose of a menu item is to do something when it is clicked, so you use the Click event procedure of the menu item to provide functionality for the menu item. The Click event does not occur only when the user clicks the menu item. The Click event also occurs if the user select the menu item using the keyboard and presses the ENTER key, or if the user presses an access key or shortcut key that is associated with the menu item. If you added the menu item at design time, you can add the event procedure by choosing the menu item by name from the Class Name drop-down list and Click from the Method Name drop-down list. If you add the menu item at design time, Visual Basic.Net automatically adds the code when you do double click on menu items.however, If you added the menu item programmatically, you need to add an event handler of the Click event of the MenuItem. You can do so by adding the following line of code to the AddMenuAndItems procedure.

104 104 AddHandler mnunew.click, AddressOf Me.mnuNew_Click AddHandler mnuclose.click, AddressOf Me.mnuClose_Click AddHandler is a keyword that associates the event (Click) of the control (mnunew) that follows the AddressOf keyword. After that you can add following code: Private Sub mnunew_click(byval sender As System.Object, ByVal e As System.EventArgs) Dim child As New Form child.mdiparent = Me i = i + 1 End Sub child.text = "Child " + CStr(i) child.show() Private Sub mnuclose_click(byval sender As System.Object, ByVal e As System.EventArgs) If me.activemdichild Is Nothing Then Else Me.ActiveMdiChild.Close( ) End Sub Context Menu/ Pop-up Menus Many windows application have shortcut menus, which are displayed when the user clicks the right mouse button over the area of the form, or over a control on the form. The menu items that appear depend upon the control on which you right click. Shortcut menus are called context menus or pop-up menus, because the particular menu items displayed depend on the context, such as the application state, or where on the form or control the right mouse button was clicked. In Visual basic.net, the ContextMenu class represents shortcut menus.

105 105 To add context menus, a new control Context Menu is added to the Windows form. The context menu does not appear on the menu bar. At design time, you can edit the context menu similar to other menus. Consider an application where context menu appears when right click on textbox control. To create a context menu, perform the following steps: 1. Open Microsoft Visual Studio Open File Menu then click on New Project. 3. Create a new Windows application. 4. Double-click ContextMenuStrip in the Toolbox. 5. The context menu is attached to the Windows form, and appears in a separate window, called component tray. 6. Add Textbox control to the windows form. Change its multiline property to True. 7. Associate the context menu with this Textbox control on the form by choosing ContextMenuStrip property and selecting name of ContextMenuStrip in the Properties window of Textbox control. 8. Now click ContextMenuStrip. Add the menu items Cut, Copy, and Paste in the context menu. 9. Write the following code for the menu items Cut, Copy and Paste. Public Class PopUpMenu Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click TextBox1.Cut() End Sub Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click TextBox1.Copy() End Sub

106 106 Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click TextBox1.Paste() End Sub Private Sub MsgboxToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MsgboxToolStripMenuItem.Click MsgBox("Welcome Students") End Sub End Class Database Connectivity Introduction

107 107 Most of the today s applications need to interact with database systems to persist, edit or view data. Data is generally stored in a relational database in the form of tables. To retrieve data from a relational database, you need to create an applicationthat allows you to connect to a database and retrieve information. ADO.NET is a model used by.net applications for communicating with a database to retrieve, access, and update data. ADO.NET ADO.NET stands for ActiveX Data Object.NET. ADO.NET is a set of classes provided in Visual Basic.NET and used to access data. ADO.Net is an object oriented framework that allows you to interact with database systems. We usually interact with database systems through SQL queries or stored procedures. The ADO.NET is based entirely on XML, and the ADO.NET object does not support the Recordset object that was supported in ADO. ADO.Net is a successor of ADO (ActiveX Data Object). The prime features of ADO.Net are its disconnected data access architecture and XML integration. Features of ADO.NET ADO.NET provides the following features: Disconnected data architecture: ADO.NET uses the disconnected data architecture. Applications connect to the database only while retrieving and updating dat. After data is retrieved, the connection with the database is closed. When the database needs to be updated, the connection is re-established. Data cached in Datasets: A dataset is most common method of accessing data because it implements a disconnected architecture. ADO.NET is based on disconnected data architecture; therefore it is not possible for the application to interact with the database to process each record. As a result, the dataa is retrieved and

108 108 stored in datasets. Dataset is a cached set of database records. You can work with the records stored in a dataset as you work with real data. Data transfer in XML format: XML is the fundamental format for data transfer in ADO.NET. Data is transferred from a database into a dataset and from the dataset to another component by the use of XML. Interaction with the database done through data commands: All operations on the database are performed by means of data commands. A data command can be an SQL statement or a stored procedure. You can retrieve, insert, delete, or modify data from a database by executing data commands. Different components of ADO.Net The famous diagram of the ADO.Net architecture and its components is presented in the figure below: Figure: ADO.NET Architecture All generic classes for data access are contained in the System.Data namespace. ADO.NET Architecture consists of two major components. The

109 Datasets 2. ADO.NET Providers A short description of the core classes of ADO.Net is presented below: Class Description DataSet The DataSet is a local buffer of tables or a collection of disconnected record sets DataTable DataTable is used to contain the data in tabular form using rows and columns. DataRow Represents a single record or row in DataTable DataRow Represents a single record or row in DataTable DataColumn Represents a column or field of DataTable DataRelation Represents the relationship between different tables in a data set. Constraint Represents the constraints or limitations that apply to a particular field or column. ADO.Net also contains some database specific classes. This means that different database system providers may provide classes (or drivers) optimized for their particular database system. The provider for such classes are called the Dot Net Framework Data Providers. ADO.NET providers are the most important elements of the ADO.NET framework. The ADO.NET providers are responsible for transferring data between a database and a Visual Basic.NET application. They are responsible for creating connection to a database and transferring data. There are two types of providers available in ADO.NETmodel: 1. SQL provider: Used for data transfer with the SQLServer. An SQL Server data provider allows fast access to a data source without going through an OLEDB or ODBC layer. The SQL Server data provider classes are present in the System.Data.SqlClient namespace. 2. OLEDB provider: Used for data transfer with different kinds of databases such as Oracle and MS Access. The OLEDB data provider classes are present in Syste.Data.OLEDB namespace. The core objects that make up a data provider are: Class Description Connection Used for establishing the connection to the data source. Command Used for executing the commands (SQL query) on the data store.

110 110 A class that connects to the database system, fetches the record and fills the dataset. It DataAdapter contains four different commands to perform database operations; Select, Update, Insert, Delete. DataReader A stream that reads data from the database in connected design. What is a data reader? The data reader is a component that reads the data from the database management system and provides it to the application. The data reader works in the connected manner; it reads a record from the DB, pass it to the application, then reads another and so on. It is a forward only means we can t move previous records. What is a dataset? A dataset is the local repository of the data used to store the tables and disconnected record set. When using disconnected architecture, all the updates are made locally to dataset and then the updates are performed to the database as a batch. What is a data adapter? A data adapter is the component that exists between the local repository (dataset) and the physical database. It contains the four different commands (SELECT, INSERT, UPDATE and DELETE). It uses these commands to fetch the data from the DB and fill into the dataset and to perform updates done in the dataset to the physical database. It is the data adapter that is responsible for opening and closing the database connection and communicates with the dataset. What is a database command? A database command specifies which particular action you want to perform to the database. The commands are in the form of SQL (Structured Query Language). There are four basic SQL statements that can be passed to the database. Data Control

111 111 A Data control is created using the Data Control tool from the toolbox. A Data control generally links one form with one table from a database. Using a data control is a two-step process. First, you place a data control on a form and set the properties to link it to a database file and table. Example: DataGridView, Dataset DatGridView control provides a customizable table for displaying data. This control is designed to be a complete solution for displaying tabular data with windows forms. Also the DataGridView class allows us to customization of cells, rows, columns, and borders through the use of its properties. Data Bound Control Data bound controls are Windows Forms controls that can easily bind with data components. Data-bound controls, such as text boxes and labels, display the actual data from the field in the attached database table. Data-bound controls will automatically display the contents of the bound field when the project runs. Data bound controls have properties, which you can set as a data component. DataSource and DisplayMember are two important properties. The controls which can become data-bound (data aware controls) are labels, text boxes, check boxes, list boxes, combo boxes, images, picture boxes, data-bound list boxes, data-bound combo boxes and data-bound grids. Difference between Data Controls and Data Bound Controls Data Control Using a data control is a two-step process. First, you place a data control on a form and set the properties to link it to a database file and table. Data Control generally links one form with one table. Prefix of data control is dat. Data Bound Control Each control is a bound to a particular field in the table. You create the control such as labels, textboxes to display the actual data. If you want to have data bound controls on second form, you must place a data control on that form. For data bound control prefix depends upon

112 112 the control which you are using. Example: DataGridView Example: ListBox, ComboBox, Label OLEDB and its uses OLEDB Stands for Object Linking and Embedding Database. OLE DB is an API designed by Microsoft for accessing different types of data sources in uniform manner. It is a set of interfaces implemented using the Component Object Model (COM). It was designed as a higher-level replacement for, and successor to, ODBC. Used for data transfer with different kinds of databases such as Oracle and MS Access. The OLEDB provider classes are present in the System.Data.OLEDB namespace. ADODB and its uses ADODB stands for ActiveX Data Object. It is a set of Component Object Model objects for accessing data sources. It provides a layer between programming languages and OLE DB. No knowledge of SQL is required to access a database when using ADO. ADO (ADODB) is a generic (COM) database library, that can be used by programming languages such as Visual Basic and C++ to access any type of database for which an OLEDB Provider has been developed. It supports Recordset object. It is used for accessing database. What are the basic steps involved in data access with ADO.Net in disconnected environment Data access using ADO.Net involves the following steps: Defining the connection string for the database server

113 113 Defining the connection (SqlConnection, OleDbConnection, etc) to the database using the connection string Defining the command (SqlCommand, OleDbCommand, etc) or command string that contains the query Defining the data adapter (SqlDataAdapter, OleDbDataAdapter, etc) using the command string and the connection object Creating a new DataSet object If the command is SELECT, filling the dataset object with the result of the query through the data adapter Reading the records from the DataTables in the datasets using the DataRow and DataColumn objects If the command is UPDATE, INSERT or DELETE, then updating the dataset through the data adapter Accepting to save the changes in the dataset to the database Creating database file Most of the today s applications need to interact with database systems to persist, edit or view data. Data is generally stored in a relational database in the form of tables. For creating Database file in MS Access perform the following steps: 1. StartAll ProgramsMicrosoft Office Open Microft Office Access Click on Office Button then click on New. 4. Name the Blank Database file and click on Create Button. 5. In Table Design view, give the Fields Name and their data types. 6. Finally save the Table. 7. If you want to create more table, then create by Table Design view and save all the tables. We can make database and tables in Oracle by the help of SQL Commands. Database Insert, Delete, Update and Navigation

114 114 Imports System.Data.OleDb Public Class Form1 Dim con As OleDbConnection = Nothing Dim cmd As OleDbCommand = Nothing Dim ds As New DataSet Dim da As OleDbDataAdapter = Nothing Dim index As Integer = 0 Dim constr As String = "Provider=Microsoft.ACE.OLEDB.12.0;data source=d:\studentdb.accdb;" Private Sub btninsert_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btninsert.click Dim rows As Integer = 0

115 115 con = New OleDbConnection(constr) con.open() Dim str As String = "Insert into Student values(" & txtroll.text & ",'" & txtname.text & "','" & txtaddress.text & "','" & txt .text & "')" cmd = New OleDbCommand(str) cmd.connection = con rows = cmd.executenonquery() If rows > 0 Then Else End If Label6.Visible = True Label6.Text = "Records inserted successfully" Label6.Text = "Records not inserted" End Sub Private Sub btnupdate_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.click Dim rows As Integer = 0 con = New OleDbConnection(constr) con.open() Dim str As String = "Update Student Set SRoll =" & txtroll.text & ",SName='" & txtname.text & "',SAddress='" & txtaddress.text & "',S ='" & txt .text & "'" cmd = New OleDbCommand(str) cmd.connection = con rows = cmd.executenonquery() con.close()

116 116 If rows > 0 Then Label6.Visible = True Label6.Text = "Records Updated successfully" Else Label6.Text = "Records not updated" End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load con = New OleDbConnection(constr) da = New OleDbDataAdapter("select * from Student", con) da.fill(ds, "Student") If ds.tables(0).rows.count = 0 Then Else txtroll.text=ds.tables("student").rows(0).item("sroll").tostring() txtname.text=ds.tables("student").rows(0).item("sname").tostring() txtaddress.text=ds.tables("student").rows(0).item("saddress").tostring() txt .text=ds.tables("student").rows(0).item("s ").tostring() End If End Sub Private Sub btndelete_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.click Dim rows As Integer = 0

117 117 con = New OleDbConnection(constr) con.open() Dim str As String = "Delete from Student where SRoll=" & txtroll.text & " " cmd = New OleDbCommand(str) cmd.connection = con rows = cmd.executenonquery() con.close() If rows > 0 Then Label6.Visible = True Label6.Text = "Records Deleted successfully" Else Label6.Text = "Records not Deleted" End If End Sub Private Sub btnreset_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnreset.click End Sub txtroll.text = "" txtname.text = "" txtaddress.text = "" txt .text = "" Private Sub btnfirst_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.click If index = 0 Then Label6.Visible = True Label6.Text = "You are already at First record"

118 118 Else Label6.Visible = False txtroll.text = ds.tables(0).rows(0).item(0).tostring() txtname.text = ds.tables(0).rows(0).item(1).tostring() txtaddress.text = ds.tables(0).rows(0).item(2).tostring() txt .text = ds.tables(0).rows(0).item(3).tostring() End If End Sub Private Sub btnnext_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.click If index = ds.tables(0).rows.count - 1 Then Label6.Visible = True Label6.Text = "You are already at Last record" Else Label6.Visible = False index = index + 1 txtroll.text = ds.tables(0).rows(index).item(0).tostring() txtname.text = ds.tables(0).rows(index).item(1).tostring() txtaddress.text=ds.tables(0).rows(index).item(2).tostring() txt .text = ds.tables(0).rows(index).item(3).tostring() End If End Sub Private Sub btnprev_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnprev.click

119 119 If index = 0 Then Label6.Visible = True Label6.Text = "You are already at First record" Else Label6.Visible = False index = index - 1 txtroll.text = ds.tables(0).rows(index).item(0).tostring() txtname.text = ds.tables(0).rows(index).item(1).tostring() txtaddress.text=ds.tables(0).rows(index).item(2).tostring() txt .text = ds.tables(0).rows(index).item(3).tostring() End If End Sub Private Sub btnlast_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.click If index = ds.tables(0).rows.count - 1 Then Else Label6.Visible = True Label6.Text = "You are already at Last record" Label6.Visible = False index = ds.tables(0).rows.count - 1 txtroll.text = ds.tables(0).rows(index).item(0).tostring() txtname.text = ds.tables(0).rows(index).item(1).tostring() txtaddress.text=ds.tables(0).rows(index).item(2).tostring() txt .text = ds.tables(0).rows(index).item(3).tostring() End If End Sub

120 120 End Class Displaying data in DataGridView(Data Control) Control Imports System.Data.OleDb Public Class Form2 Dim con As OleDbConnection = Nothing Dim ds As New DataSet Dim da As OleDbDataAdapter = Nothing Dim constr As String = "Provider=Microsoft.ACE.OLEDB.12.0;data source=d:\studentdb.accdb;" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click con = New OleDbConnection(constr) con.open() Dim str As String = "Select * from Student" da = New OleDbDataAdapter(str, con) da.fill(ds, "Student") DataGridView1.DataSource = ds.tables("student") con.close() End Sub End Class

121 121

CST242 Windows Forms with C# Page 1

CST242 Windows Forms with C# Page 1 CST242 Windows Forms with C# Page 1 1 2 4 5 6 7 9 10 Windows Forms with C# CST242 Visual C# Windows Forms Applications A user interface that is designed for running Windows-based Desktop applications A

More information

Controls. By the end of this chapter, student will be able to:

Controls. By the end of this chapter, student will be able to: Controls By the end of this chapter, student will be able to: Recognize the (Properties Window) Adjust the properties assigned to Controls Choose the appropriate Property Choose the proper value for the

More information

Chapter 1:- Introduction to.net. Compiled By:- Ankit Shah Assistant Professor, SVBIT.

Chapter 1:- Introduction to.net. Compiled By:- Ankit Shah Assistant Professor, SVBIT. Chapter 1:- Introduction to.net Compiled By:- Assistant Professor, SVBIT. What is.net? 2 Microsoft s vision of the future of applications in the Internet age Increased robustness over classic Windows apps

More information

B.V Patel Institute of BMC & IT, UTU

B.V Patel Institute of BMC & IT, UTU Corse Code and Corse Name: 030010401-GUI Programming Unit 1. Introduction to.net Framework Short Questions 1. What is.net Framework? 2. What is VB.NET? 3. Which are the main components of.net Framework?

More information

Programming in C# Project 1:

Programming in C# Project 1: Programming in C# Project 1: Set the text in the Form s title bar. Change the Form s background color. Place a Label control on the Form. Display text in a Label control. Place a PictureBox control on

More information

Chapter 12: Using Controls

Chapter 12: Using Controls Chapter 12: Using Controls Examining the IDE s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton A Label has been dragged onto Form1

More information

New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other

New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other C#.NET? New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other OO languages. Small learning curve from either

More information

Dive Into Visual C# 2010 Express

Dive Into Visual C# 2010 Express Dive Into Visual C# 2010 Express 2 Seeing is believing. Proverb Form ever follows function. Louis Henri Sullivan Intelligence is the faculty of making artificial objects, especially tools to make tools.

More information

Tutorial 3 - Welcome Application

Tutorial 3 - Welcome Application 1 Tutorial 3 - Welcome Application Introduction to Visual Programming Outline 3.1 Test-Driving the Welcome Application 3.2 Constructing the Welcome Application 3.3 Objects used in the Welcome Application

More information

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events Working with Form: properties, methods and events To create a New Window Forms Application, Select File New Project. It will open one dialog box which is shown in Fig 2.1. Fig 2.1 The New Project dialog

More information

Microsoft Visual C# 2005: Developing Applications Table of Contents

Microsoft Visual C# 2005: Developing Applications Table of Contents Table of Contents INTRODUCTION...INTRO-1 Prerequisites...INTRO-2 Installing the Practice Files...INTRO-3 Software Requirements...INTRO-3 Sample Database...INTRO-3 Security...INTRO-4 Installation...INTRO-4

More information

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction 1. Which language is not a true object-oriented programming language? A. VB 6 B. VB.NET C. JAVA D. C++ 2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a)

More information

Introductionto the Visual Basic Express 2008 IDE

Introductionto the Visual Basic Express 2008 IDE 2 Seeing is believing. Proverb Form ever follows function. Louis Henri Sullivan Intelligence is the faculty of making artificial objects, especially tools to make tools. Henri-Louis Bergson Introductionto

More information

1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart?

1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart? 1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart? 6. Define Visual Basic.NET? 7. Define programming language?

More information

Program Contents: DOTNET TRAINING IN CHENNAI

Program Contents: DOTNET TRAINING IN CHENNAI DOTNET TRAINING IN CHENNAI NET Framework - In today s world of enterprise application development either desktop or Web, one of leaders and visionary is Microsoft.NET technology. The.NET platform also

More information

UNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net

UNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net UNIT 1 Introduction to Microsoft.NET framework and Basics of VB.Net 1 SYLLABUS 1.1 Overview of Microsoft.NET Framework 1.2 The.NET Framework components 1.3 The Common Language Runtime (CLR) Environment

More information

Vision V sion o n I n n 1975 V sion o n T o T d o a d y A c o c m o pu p t u er e o n o n e v e e v r e y E po p w o er e p e p o e p o l p e

Vision V sion o n I n n 1975 V sion o n T o T d o a d y A c o c m o pu p t u er e o n o n e v e e v r e y E po p w o er e p e p o e p o l p e Mobile Applications.. Vision Vision In 1975 A computer on every desk and in every home Vision Today Empower people through great software any time, any place, and on any device Mobility Group Empower people

More information

Full file at https://fratstock.eu Programming in Visual Basic 2010

Full file at https://fratstock.eu Programming in Visual Basic 2010 OBJECTIVES: Chapter 2 User Interface Design Upon completion of this chapter, your students will be able to 1. Use text boxes, masked text boxes, rich text boxes, group boxes, check boxes, radio buttons,

More information

Getting started 7. Setting properties 23

Getting started 7. Setting properties 23 Contents 1 2 3 Getting started 7 Introducing Visual Basic 8 Installing Visual Studio 10 Exploring the IDE 12 Starting a new project 14 Adding a visual control 16 Adding functional code 18 Saving projects

More information

Department of Computer Applications

Department of Computer Applications MCA 512:.NET framework and C# [Part I : Medium Answer type Questions] Unit - 1 Q1. What different tools are available and used to develop.net Applications? Hint a).net Framework SDK b) ASP.NET Web Matrix

More information

A NET Refresher

A NET Refresher .NET Refresher.NET is the latest version of the component-based architecture that Microsoft has been developing for a number of years to support its applications and operating systems. As the name suggests,.net

More information

AC I Sem 5_TYCS. ASP.NET application codes can be written in any of the following languages:

AC I Sem 5_TYCS. ASP.NET application codes can be written in any of the following languages: Chapter 1-Overview of.net Framework What is ASP.NET? ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required to

More information

Getting started 7. Setting properties 23

Getting started 7. Setting properties 23 Contents 1 2 3 Getting started 7 Introduction 8 Installing Visual Basic 10 Exploring the IDE 12 Starting a new project 14 Adding a visual control 16 Adding functional code 18 Saving projects 20 Reopening

More information

2 USING VB.NET TO CREATE A FIRST SOLUTION

2 USING VB.NET TO CREATE A FIRST SOLUTION 25 2 USING VB.NET TO CREATE A FIRST SOLUTION LEARNING OBJECTIVES GETTING STARTED WITH VB.NET After reading this chapter, you will be able to: 1. Begin using Visual Studio.NET and then VB.NET. 2. Point

More information

GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4

GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4 GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4 Subject Name VISUAL BASIC Sr.No Course content 1. 1. Introduction to Visual Basic 1.1. Programming Languages 1.1.1. Procedural,

More information

Introduction to.net Framework

Introduction to.net Framework Introduction to.net Framework .NET What Is It? Software platform Language neutral In other words:.net is not a language (Runtime and a library for writing and executing written programs in any compliant

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 System.Drawing Namespace System.Windows.Forms Namespace Creating forms applications by hand Creating forms applications using Visual Studio designer Windows applications also look different from console

More information

Chapter 12: Using Controls

Chapter 12: Using Controls Chapter 12: Using Controls Using a LinkLabel LinkLabel Similar to a Label Provides the additional capability to link the user to other sources Such as Web pages or files Default event The method whose

More information

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming Introduction to the Visual Studio.NET Integrated Development Environment IDE CSC 211 Intermediate Programming Visual Studio.NET Integrated Development Environment (IDE) The Start Page(Fig. 1) Helpful links

More information

Visual Studio.NET enables quick, drag-and-drop construction of form-based applications

Visual Studio.NET enables quick, drag-and-drop construction of form-based applications Visual Studio.NET enables quick, drag-and-drop construction of form-based applications Event-driven, code-behind programming Visual Studio.NET WinForms Controls Part 1 Event-driven, code-behind programming

More information

2609 : Introduction to C# Programming with Microsoft.NET

2609 : Introduction to C# Programming with Microsoft.NET 2609 : Introduction to C# Programming with Microsoft.NET Introduction In this five-day instructor-led course, developers learn the fundamental skills that are required to design and develop object-oriented

More information

PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city) Bangalore

PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city) Bangalore PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city) Bangalore 560 100 Department of MCA COURSE INFORMATION SHEET Programming Using C#.NET (13MCA53) 1. GENERAL INFORMATION: Academic Year:

More information

Lecture 1 Introduction Phil Smith

Lecture 1 Introduction Phil Smith 2014-2015 Lecture 1 Introduction Phil Smith Learning Outcomes LO1 Understand the principles of object oriented programming LO2 Be able to design object oriented programming solutions LO3 Be able to implement

More information

Dive Into Visual C# 2008 Express

Dive Into Visual C# 2008 Express 1 2 2 Dive Into Visual C# 2008 Express OBJECTIVES In this chapter you will learn: The basics of the Visual Studio Integrated Development Environment (IDE) that assists you in writing, running and debugging

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 System.Drawing Namespace System.Windows.Forms Namespace Creating forms applications by hand Creating forms applications using Visual Studio designer Windows applications also look different from console

More information

Introduction to.net Framework Week 1. Tahir Nawaz

Introduction to.net Framework Week 1. Tahir Nawaz Introduction to.net Framework Week 1 Tahir Nawaz .NET What Is It? Software platform Language neutral In other words:.net is not a language (Runtime and a library for writing and executing written programs

More information

Visual Basic.NET. 1. Which language is not a true object-oriented programming language?

Visual Basic.NET. 1. Which language is not a true object-oriented programming language? Visual Basic.NET Objective Type Questions 1. Which language is not a true object-oriented programming language? a.) VB.NET b.) VB 6 c.) C++ d.) Java Answer: b 2. A GUI: a.) uses buttons, menus, and icons.

More information

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies for web applications development using ASP.NET, XML,

More information

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank)

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank) Unit-1 (overview of Microsoft.net framework) 1. What is CLR? What is its use? (2 times) 2 2. What is garbage collection? 2 3. Explain MSIL 2 4. Explain CTS in detail 2 5. List the extension of files available

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies Overview of Microsoft.Net Framework: The Dot Net or.net is a technology that is an outcome of Microsoft s new strategy to develop window based robust applications and rich web applications and to keep

More information

Unit 1: Visual Basic.NET and the.net Framework

Unit 1: Visual Basic.NET and the.net Framework 1 Chapter1: Visual Basic.NET and the.net Framework Unit 1: Visual Basic.NET and the.net Framework Contents Introduction to.net framework Features Common Language Runtime (CLR) Framework Class Library(FCL)

More information

UNIT 3 ADDITIONAL CONTROLS AND MENUS OF WINDOWS

UNIT 3 ADDITIONAL CONTROLS AND MENUS OF WINDOWS UNIT 3 ADDITIONAL CONTROLS AND MENUS OF WINDOWS 1 SYLLABUS 3.1 Working with other controls of toolbox : 3.1.1 Date Time Picker 3.1.2 List Box 3.1.2.1 Item collection 3.1.3 Combo Box 3.1.4 Picture Box 3.15

More information

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

Developing Microsoft.NET Applications for Windows (Visual Basic.NET) Developing Microsoft.NET Applications for Windows (Visual Basic.NET) Course Number: 2565 Length: 5 Day(s) Certification Exam This course will help you prepare for the following Microsoft Certified Professional

More information

CIS 3260 Intro. to Programming with C#

CIS 3260 Intro. to Programming with C# Introduction to Programming and Visual C# 2008 McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Describe the process of visual program design and development Explain the term object-oriented

More information

Overview Describe the structure of a Windows Forms application Introduce deployment over networks

Overview Describe the structure of a Windows Forms application Introduce deployment over networks Windows Forms Overview Describe the structure of a Windows Forms application application entry point forms components and controls Introduce deployment over networks 2 Windows Forms Windows Forms are classes

More information

M Introduction to C# Programming with Microsoft.NET - 5 Day Course

M Introduction to C# Programming with Microsoft.NET - 5 Day Course Module 1: Getting Started This module presents the concepts that are central to the Microsoft.NET Framework and platform, and the Microsoft Visual Studio.NET integrated development environment (IDE); describes

More information

Philadelphia University Faculty of Information Technology. Visual Programming

Philadelphia University Faculty of Information Technology. Visual Programming Philadelphia University Faculty of Information Technology Visual Programming Using C# -Work Sheets- Prepared by: Dareen Hamoudeh Eman Al Naji Work Sheet 1 Form, Buttons and labels Properties Changing properties

More information

Unit 3 Additional controls and Menus of Windows

Unit 3 Additional controls and Menus of Windows Working with other controls of toolbox: DateTime Picker If you want to enable users to select a date and time, and to display that date and time in the specified format, use the DateTimePicker control.

More information

Using Visual Basic Studio 2008

Using Visual Basic Studio 2008 Using Visual Basic Studio 2008 Recall that object-oriented programming language is a programming language that allows the programmer to use objects to accomplish a program s goal. An object is anything

More information

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline 2 T U T O R I A L Objectives In this tutorial, you will learn to: Navigate Visual Studio.NET s Start Page. Create a Visual Basic.NET solution. Use the IDE s menus and toolbars. Manipulate windows in the

More information

DateTimePicker Control

DateTimePicker Control Controls Part 2 DateTimePicker Control Used for representing Date/Time information and take it as input from user. Date information is automatically created. Prevents wrong date and time input. Fundamental

More information

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In-

More information

Chapter 2. Creating Applications with Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

Chapter 2. Creating Applications with Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 2 Creating Applications with Visual Basic Addison Wesley is an imprint of 2011 Pearson Addison-Wesley. All rights reserved. Section 2.1 FOCUS ON PROBLEM SOLVING: BUILDING THE DIRECTIONS APPLICATION

More information

VB.NET. Q.1 Explain.Net Framework Architecture. OR Components of.net Framework

VB.NET. Q.1 Explain.Net Framework Architecture. OR Components of.net Framework Q.1 Explain.Net Framework Architecture. OR Components of.net Framework Net Framework is a platform that provides tools and technologies to develop Windows, Web and Enterprise applications. It mainly contains

More information

Model Question Paper. Credits: 4 Marks: 140. Part A (One mark questions)

Model Question Paper. Credits: 4 Marks: 140. Part A (One mark questions) Model Question Paper Subject Code: MT0040 Subject Name: VB.Net Credits: 4 Marks: 140 (One mark questions) 1. The is a systematic class framework used for the development of system tools and utilities.

More information

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank)

M. K. Institute Of Computer Studies, Bharuch SYBCA SEM IV VB.NET (Question Bank) Unit-1 (overview of Microsoft.net framework) 1. What is CLR? What is its use? (2 times) 2 2. What is garbage collection? 2 3. Explain MSIL (mar/apr-201) 2 times 2 4. Explain CTS in detail 2 5. List the

More information

DOT NET SYLLABUS FOR 6 MONTHS

DOT NET SYLLABUS FOR 6 MONTHS DOT NET SYLLABUS FOR 6 MONTHS INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate

More information

C# Syllabus. MS.NET Framework Introduction

C# Syllabus. MS.NET Framework Introduction C# Syllabus MS.NET Framework Introduction The.NET Framework - an Overview Framework Components Framework Versions Types of Applications which can be developed using MS.NET MS.NET Base Class Library MS.NET

More information

Dot Net Online Training

Dot Net Online Training chakraitsolutions.com http://chakraitsolutions.com/dotnet-online-training/ Dot Net Online Training DOT NET Online Training CHAKRA IT SOLUTIONS TO LEARN ABOUT OUR UNIQUE TRAINING PROCESS: Title : Dot Net

More information

COPYRIGHTED MATERIAL. Visual Basic: The Language. Part 1

COPYRIGHTED MATERIAL. Visual Basic: The Language. Part 1 Part 1 Visual Basic: The Language Chapter 1: Getting Started with Visual Basic 2010 Chapter 2: Handling Data Chapter 3: Visual Basic Programming Essentials COPYRIGHTED MATERIAL Chapter 1 Getting Started

More information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 1 An Introduction to Visual Basic 2005 Objectives After studying this chapter, you should be able to: Explain the history of programming languages

More information

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1 Chapter 12 Microsoft Assemblies 1 Process Phases Discussed in This Chapter Requirements Analysis Design Framework Architecture Detailed Design Key: x = main emphasis x = secondary emphasis Implementation

More information

List and Value Controls

List and Value Controls List and Value Controls Sorting in List-Based Controls You can sort the objects displayed in a list-based control by setting the Sorted property to True, as shown here: listbox1.sorted = true; Setting

More information

Interface Design in C#

Interface Design in C# Interface Design in C# Project 1: Copy text from TextBox to Label as shown in the figure. TextBox and Label have the same property: display.text = nameentry.text; private void nameentry_textchanged display.text

More information

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6 Contents ***Introduction*** Introduction to Programming... 1 Introduction... 2 What is a Program?... 2 Role Played by a Program to Perform a Task... 2 What is a Programming Language?... 3 Types of Programming

More information

.NET-6Weeks Project Based Training

.NET-6Weeks Project Based Training .NET-6Weeks Project Based Training Core Topics 1. C# 2. MS.Net 3. ASP.NET 4. 1 Project MS.NET MS.NET Framework The.NET Framework - an Overview Architecture of.net Framework Types of Applications which

More information

.Net. Course Content ASP.NET

.Net. Course Content ASP.NET .Net Course Content ASP.NET INTRO TO WEB TECHNOLOGIES HTML ü Client side scripting langs ü lls Architecture ASP.NET INTRODUCTION ü What is ASP.NET ü Image Technique and code behind technique SERVER SIDE

More information

Computer Science 110. NOTES: module 8

Computer Science 110. NOTES: module 8 Computer Science 110 NAME: NOTES: module 8 Introducing Objects As we have seen, when a Visual Basic application runs, it displays a screen that is similar to the Windows-style screens. When we create a

More information

2559 : Introduction to Visual Basic.NET Programming with Microsoft.NET

2559 : Introduction to Visual Basic.NET Programming with Microsoft.NET 2559 : Introduction to Visual Basic.NET Programming with Microsoft.NET Introduction Elements of this syllabus are subject to change. This five-day instructor-led course provides students with the knowledge

More information

SPARK. User Manual Ver ITLAQ Technologies

SPARK. User Manual Ver ITLAQ Technologies SPARK Forms Builder for Office 365 User Manual Ver. 3.5.50.102 0 ITLAQ Technologies www.itlaq.com Table of Contents 1 The Form Designer Workspace... 3 1.1 Form Toolbox... 3 1.1.1 Hiding/ Unhiding/ Minimizing

More information

DOT NET Syllabus (6 Months)

DOT NET Syllabus (6 Months) DOT NET Syllabus (6 Months) THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In- Time Compilation and CLS Disassembling.Net Application to IL

More information

Full file at

Full file at T U T O R I A L 3 Objectives In this tutorial, you will learn to: Set the text in the Form s title bar. Change the Form s background color. Place a Label control on the Form. Display text in a Label control.

More information

GUI Design and Event- Driven Programming

GUI Design and Event- Driven Programming 4349Book.fm Page 1 Friday, December 16, 2005 1:33 AM Part 1 GUI Design and Event- Driven Programming This Section: Chapter 1: Getting Started with Visual Basic 2005 Chapter 2: Visual Basic: The Language

More information

.Net Interview Questions

.Net Interview Questions .Net Interview Questions 1.What is.net? NET is an integral part of many applications running on Windows and provides common functionality for those applications to run. This download is for people who

More information

LESSON A. The Splash Screen Application

LESSON A. The Splash Screen Application The Splash Screen Application LESSON A LESSON A After studying Lesson A, you should be able to: Start and customize Visual Studio 2010 or Visual Basic 2010 Express Create a Visual Basic 2010 Windows application

More information

Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Rapid Application Development By: S. Sabraz Nawaz

Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Rapid Application Development By: S. Sabraz Nawaz Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Rapid Application Development By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce Rapid Application

More information

Visual Programming 1. What is Visual Basic? 2. What are different Editions available in VB? 3. List the various features of VB

Visual Programming 1. What is Visual Basic? 2. What are different Editions available in VB? 3. List the various features of VB Visual Programming 1. What is Visual Basic? Visual Basic is a powerful application development toolkit developed by John Kemeny and Thomas Kurtz. It is a Microsoft Windows Programming language. Visual

More information

Program and Graphical User Interface Design

Program and Graphical User Interface Design CHAPTER 2 Program and Graphical User Interface Design OBJECTIVES You will have mastered the material in this chapter when you can: Open and close Visual Studio 2010 Create a Visual Basic 2010 Windows Application

More information

Saikat Banerjee Page 1

Saikat Banerjee Page 1 1.What is.net? NET is an integral part of many applications running on Windows and provides common functionality for those applications to run. This download is for people who need.net to run an application

More information

Lecture 5 COMMON CONTROLS

Lecture 5 COMMON CONTROLS Lecture 5 COMMON CONTROLS 1. The ListBox Class Represents a box that contains a list of items. The following are its some of its more important properties: MultiColumn This is a Boolean that indicates

More information

B.V Patel Institute of Business Management, Computer & Information Technology

B.V Patel Institute of Business Management, Computer & Information Technology BCA (Semester 4 th ) 030010401: GUI Programming Teaching Schedule Objective: To provide fundamentals of.net framework, C# language and to introduce development of rich Windows form applications with event

More information

Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Visual Programming By: S. Sabraz Nawaz

Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Visual Programming By: S. Sabraz Nawaz Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Visual Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce South Eastern University

More information

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static Table of Contents Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static Series Chart with Dynamic Series Master-Detail

More information

SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM ( )

SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM ( ) SECURED PROGRAMMING IN.NET DETAILED TRAINING CONTENT INDUSTRIAL TRAINING PROGRAM (2013-2014) MODULE: C# PROGRAMMING CHAPTER 1: INTRODUCING.NET AND C# 1.1 INTRODUCTION TO LANGUAGES C++ C# DIFFERENCES BETWEEN

More information

November Copyright 2016 Open Systems Holdings Corp. All rights reserved.

November Copyright 2016 Open Systems Holdings Corp. All rights reserved. This document describes the intended features and technology for TRAVERSE 11 as of November, 2016. Features and technology are subject to change and there is no guarantee that any particular feature or

More information

EEE-425 Programming Languages (2013) 1

EEE-425 Programming Languages (2013) 1 2 Computer programming: creating a sequence of instructions to enable the computer to do something Programmers do not use machine language when creating computer programs. Instead, programmers tend to

More information

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations Part I Integrated Development Environment Chapter 1: A Quick Tour Chapter 2: The Solution Explorer, Toolbox, and Properties Chapter 3: Options and Customizations Chapter 4: Workspace Control Chapter 5:

More information

This page intentionally left blank

This page intentionally left blank This page intentionally left blank Starting Out With Visual Basic: International Edition Table of Contents Cover Contents Preface Chapter 1 Introduction to Programming and Visual Basic 1.1 Computer Systems:

More information

StarTeam Layout Designer Help

StarTeam Layout Designer Help StarTeam 16.3 Layout Designer Help Micro Focus The Lawn 22-30 Old Bath Road Newbury, Berkshire RG14 1QN UK http://www.microfocus.com Copyright Micro Focus 2018. All rights reserved. MICRO FOCUS, the Micro

More information

Event-based Programming

Event-based Programming Window-based programming Roger Crawfis Most modern desktop systems are window-based. What location do I use to set this pixel? Non-window based environment Window based environment Window-based GUI s are

More information

Chapter 2 Exploration of a Visual Basic.Net Application

Chapter 2 Exploration of a Visual Basic.Net Application Chapter 2 Exploration of a Visual Basic.Net Application We will discuss in this chapter the structure of a typical Visual Basic.Net application and provide you with a simple project that describes the

More information

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET VB.NET Module 1: Getting Started This module introduces Visual Basic.NET and explains how it fits into the.net platform. It explains how to use the programming tools in Microsoft Visual Studio.NET and

More information

What s New Essential Studio User Interface Edition

What s New Essential Studio User Interface Edition What s New Essential Studio User Interface Edition Table of Contents Essential Grid... 3 Grid for ASP.NET... 3 Grid for ASP.NET MVC... 3 Grid for Silverlight... 9 Grid for WPF... 10 Essential Tools...

More information

Unit 3. Lesson Designing User Interface-2. TreeView Control. TreeView Contol

Unit 3. Lesson Designing User Interface-2. TreeView Control. TreeView Contol Designing User Interface-2 Unit 3 Designing User Interface-2 Lesson 3.1-3 TreeView Control A TreeView control is designed to present a list in a hierarchical structure. It is similar to a directory listing.

More information

NiceForm User Guide. English Edition. Rev Euro Plus d.o.o. & Niceware International LLC All rights reserved.

NiceForm User Guide. English Edition. Rev Euro Plus d.o.o. & Niceware International LLC All rights reserved. www.nicelabel.com, info@nicelabel.com English Edition Rev-0910 2009 Euro Plus d.o.o. & Niceware International LLC All rights reserved. www.nicelabel.com Head Office Euro Plus d.o.o. Ulica Lojzeta Hrovata

More information

Skill Area 336 Explain Essential Programming Concept. Programming Language 2 (PL2)

Skill Area 336 Explain Essential Programming Concept. Programming Language 2 (PL2) Skill Area 336 Explain Essential Programming Concept Programming Language 2 (PL2) 336.1-Examine Basic Language Environment 336.1.1 Describe the basic operating environment of the language 336.1.2 Define

More information

Working with PDF s. To open a recent file on the Start screen, double click on the file name.

Working with PDF s. To open a recent file on the Start screen, double click on the file name. Working with PDF s Acrobat DC Start Screen (Home Tab) When Acrobat opens, the Acrobat Start screen (Home Tab) populates displaying a list of recently opened files. The search feature on the top of the

More information

TRAINING GUIDE FOR OPC SYSTEMS.NET. Simple steps to successful development and deployment. Step by Step Guide

TRAINING GUIDE FOR OPC SYSTEMS.NET. Simple steps to successful development and deployment. Step by Step Guide TRAINING GUIDE FOR OPC SYSTEMS.NET Simple steps to successful development and deployment. Step by Step Guide SOFTWARE DEVELOPMENT TRAINING OPC Systems.NET Training Guide Open Automation Software Evergreen,

More information

Programming in Visual Basic with Microsoft Visual Studio 2010

Programming in Visual Basic with Microsoft Visual Studio 2010 Programming in Visual Basic with Microsoft Visual Studio 2010 Course 10550; 5 Days, Instructor-led Course Description This course teaches you Visual Basic language syntax, program structure, and implementation

More information

Tutorial 2 - Welcome Application Introducing, the Visual Studio.NET IDE

Tutorial 2 - Welcome Application Introducing, the Visual Studio.NET IDE 1 Tutorial 2 - Welcome Application Introducing, the Visual Studio.NET IDE Outline 2.1 Test-Driving the Welcome Application 2.2 Overview of the Visual Studio.NET 2003 IDE 2.3 Creating a Project for the

More information