Unit 4 Advanced Features of VB.Net

Similar documents
Darshan Institute of Engineering & Technology for Diploma Studies

Working with Printers

Chapter 6 Dialogs. Creating a Dialog Style Form

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

Multimedia. If the user is working on a spreadsheet, he or she may start typing numbers and performing calculations.

Objectives. After completing this topic, the students will: Understand of the concept of polymorphism Know on How to implement 2 types of polymorphism

Index. B base classes creating, , 389 inheriting, inheriting in new classes, 390

Learning VB.Net. Tutorial 17 Classes

Ingegneria del Software T. Interfaccia utente

VB.NET Programs. ADO.NET (insert, update, view records)

(Subroutines in Visual Basic)

CIS 3260 Intro to Programming with C#

Unit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types

Module 8: Building a Windows Forms User Interface

Menus, Common Dialog Controls, Context Menus, Sub Procedures, and Functions

Lesson 09 Working with. SDI and MDI. MIT 31043: Rapid Application Development By: S. Sabraz Nawaz Senior Lecturer in MIT Dept. of MIT, FMC, SEUSL

In this tutorial we will create a simple calculator to Add/Subtract/Multiply and Divide two numbers and show a simple message box result.

Files. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies

Windows 7 Control Pack for WinForms

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

A Complete Tutorial for Beginners LIEW VOON KIONG

Tutorial 03 understanding controls : buttons, text boxes

Programming. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies

Chapter 2. Building Multitier Programs with Classes The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Keeping Track, Menus. CSC 330 Object-Oriented Programming 1

FOR 240 Homework Assignment 4 Using DBGridView and Other VB Controls to Manipulate Database Introduction to Computing in Natural Resources

Laboratorio di Ingegneria del Software

Laboratorio di Ingegneria del L-A

COPYRIGHTED MATERIAL. Visual Basic: The Language. Part 1

Learning VB.Net. Tutorial 10 Collections

Applications with Multiple Forms

GUI Design and Event- Driven Programming

MapWindow Plug-in Development

Creating a Transacted Resource Using System.Transactions (Lab 2) (Visual C#, Visual Basic)

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

Running the Altair SIMH from.net programs

Procedures in Visual Basic

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

Menus and Printing. Menus. A focal point of most Windows applications

12/14/2016. Errors. Debugging and Error Handling. Run-Time Errors. Debugging in C# Debugging in C# (continued)

C# 2008 and.net Programming for Electronic Engineers - Elektor - ISBN

Part 4 - Procedures and Functions

Lecture 10 OOP and VB.Net

Full file at Chapter 2 - Inheritance and Exception Handling

Instructor s Notes Programming Logic Printing Reports. Programming Logic. Printing Custom Reports

BBM 102 Introduction to Programming II Spring Exceptions

Learning VB.Net. Tutorial 19 Classes and Inheritance

Final Exam 7:00-10:00pm, April 14, 2008

Use Default Form Instances

Chapter 11. Data Files The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Introduction to C# Applications

Level 3 Computing Year 2 Lecturer: Phil Smith

BBM 102 Introduction to Programming II Spring 2017

CS 162, Lecture 25: Exam II Review. 30 May 2018

Object Oriented Programming

CS159. Nathan Sprague

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

Q&As. Microsoft MTA Software Development Fundamentals. Pass Microsoft Exam with 100% Guarantee

Mr.Khaled Anwar ( )

Revision for Final Examination (Second Semester) Grade 9

Design Of Human Computer Interfaces Assignment 1- Hello World. Compliance Report

VB.NET MOCK TEST VB.NET MOCK TEST I

Lesson 09 Working with. SDI and MDI. MIT Rapid Application Development By. S. Sabraz Nawaz Lecturer in MIT

This page intentionally left blank

Learning VB.Net. Tutorial 16 Modules

Check out the demo video of this application so you know what you will be making in this tutorial.

I101/B100 Problem Solving with Computers

Object-Oriented Programming

Chapter 8 Advanced GUI Features

IMS1906: Business Software Fundamentals Tutorial exercises Week 5: Variables and Constants

Introduction to Programming Using Java (98-388)

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

Programming with Microsoft Visual Basic.NET. Array. What have we learnt in last lesson? What is Array?

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

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

Context-sensitive Help

To enter the number in decimals Label 1 To show total. Text:...

Chapter 12: Using Controls

The following are required to duplicate the process outlined in this document.

Lab 4: Adding a Windows User-Interface

Table of Contents CONSOLE BASED APPLICATION 2

Disclaimer. Trademarks. Liability

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35

Inheriting Windows Forms with Visual C#.NET

Before We Begin. Introduction to Computer Use II. Overview (1): Winter 2006 (Section M) CSE 1530 Winter Bill Kapralos.

Exception Handling. Sometimes when the computer tries to execute a statement something goes wrong:

Computing Science Unit 1

CST242 Windows Forms with C# Page 1

Chapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.

Exception Handling. Run-time Errors. Methods Failure. Sometimes when the computer tries to execute a statement something goes wrong:

IS 0020 Program Design and Software Tools

WinForms Applications

Fig 1.1.NET Framework Architecture Block Diagram

To get started with Visual Basic 2005, I recommend that you jump right in

Building Multitier Programs with Classes

Chapter 2 Exploration of a Visual Basic.Net Application

Developing Applications Using Visual Basic 2008: Volume 2

Exception Handling in C++

Script Step Reference Information

Procedural programs are ones in which instructions are executed in the order defined by the programmer.

Transcription:

Dialog Boxes There are many built-in dialog boxes to be used in Windows forms for various tasks like opening and saving files, printing a page, providing choices for colors, fonts, page setup, etc., to the user of an application. The main purpose of built-in dialog boxes is to reduce the developer's time and workload. The following lists are the commonly used dialog box controls. o ColorDialog o FontDialog o OpenFileDialog o SaveFileDialog o PrintDialog All of these dialog box control classes inherit from the CommonDialog class and override the RunDialog() function of the base class to create the specific dialog box. The RunDialog() function is automatically invoked when a user of a dialog box calls its ShowDialog() function. The ShowDialog method is used to display all the dialog box controls at run-time. It returns a value of the type of DialogResult enumeration. The values of DialogResult enumeration are described in below table: Value Abort Cancel No None OK Retry Yes Returns DialogResult.Abort value, when user clicks an Abort button. Returns DialogResult.Cancel, when user clicks a Cancel button. Returns DialogResult.No, when user clicks a No button. Returns nothing and the dialog box continues running. Returns DialogResult.OK, when user clicks an OK button Returns DialogResult.Retry, when user clicks an Retry button Returns DialogResult.Yes, when user clicks an Yes button 1. ColorDialog o It represents a common dialog box that displays available colors along with controls that enable the user to define custom colors. o It lets the user select a color. o The main property of the ColorDialog control is Color, which returns a Color object. Properties: Property Name AnyColor Color CustomColors FullOpen It gets or sets a value indicating whether the dialog box displays all available colors in the set of basic colors. It gets or sets the color selected by the user. It gets or sets the set of custom colors shown in the dialog box. It gets or sets a value indicating whether the controls used to create custom 1 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

ShowHelp Methods: Method Name Reset RunDialog ShowDialog Events: Method Name HelpRequest colors are visible when the dialog box is opened It gets or sets a value indicating whether a Help button appears in the color dialog box. Resets all options to their default values, the last selected color to black, and the custom colors to their default values. When overridden in a derived class, specifies a common dialog box. Runs a common dialog box with a default owner. Occurs when the user clicks the Help button on a common dialog box. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ColorDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then Label1.ForeColor = ColorDialog1.Color End If 2. FontDialog o It prompts the user to choose a font from among those installed on the local computer and lets the user select the font, font size, and color. o It returns the Font and Color objects. Properties: Property Name Color Font It gets or sets the selected font color. It gets or sets the selected font. 2 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

MaxSize MinSize ShowEffects ShowHelp It gets or sets the maximum point size a user can select. It gets or sets the minimum point size a user can select. It gets or sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options. It gets or sets a value indicating whether the dialog box displays a Help button. Methods: Method Name Reset RunDialog ShowDialog Events: Method Name Apply Resets all options to their default values, the last selected color to black, and the custom colors to their default values. When overridden in a derived class, specifies a common dialog box. Runs a common dialog box with a default owner. Occurs when the Apply button on the font dialog box is clicked. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If FontDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then TextBox1.ForeColor = FontDialog1.Color TextBox1.Font = FontDialog1.Font End If 3. OpenFileDialog o The OpenFileDialog control prompts the user to open a file and allows the user to select a file to open. o The user can check if the file exists and then open it. o The OpenFileDialog control class inherits from the abstract class FileDialog. 3 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Properties: Property Name AddExtension CheckFileExists CheckPathExists FileName Multiselect ShowHelp Title ValidateNames Methods: Method Name OpenFile Reset It gets or sets a value indicating whether the dialog box automatically adds extension to a file name if the user omits the extension. It gets or sets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist. It gets or sets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist. It gets or sets a string containing the file name selected in the file dialog box. It gets or sets a value indicating whether the dialog box allows multiple files to be selected. It gets or sets a value indicating whether the Help button is displayed in the file dialog box. It gets or sets the file dialog box title. It gets or sets a value indicating whether the dialog box accepts only valid Win32 file names. Opens the file selected by the user, with read-only permission. The file is specified by the FileName property. Resets all options to their default value. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If OpenFileDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName) End If 4 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

4. SaveFileDialog o The SaveFileDialog control prompts the user to select a location for saving a file and allows the user to specify the name of the file to save data. o The SaveFileDialog control class inherits from the abstract class FileDialog. Properties: Properties are same as the Open Dialog. Methods: Methods are same as the Open Dialog. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SaveFileDialog1.Filter = "TXT Files (*txt*) *.txt" If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, True) End If 5. PrintDialog o The PrintDialog control lets the user to print documents by selecting a printer and choosing which sections of the document to print from a Windows Forms application. o There are various other controls related to printing of documents. The list of other controls are given below: PrintDocument control: It provides support for actual events and operations of printing in Visual Basic and sets the properties for printing. PrinterSettings control: It is used to configure how a document is printed by specifying the printer. 5 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

PageSetUpDialog control: It allows the user to specify page-related print settings including page orientation, paper size and margin size. PrintPreviewControl control: It represents the raw preview part of print previewing from a Windows Forms application, without any dialog boxes or buttons. PrintPreviewDialog control: It represents a dialog box form that contains a PrintPreviewControl for printing from a Windows Forms application. Properties: Property Name AllowCurrentPage AllowPrintToFile AllowSelection PrinterSettings Document PrintToFile ShowHelp Methods: Method Name Reset RunDialog ShowDialog It gets or sets a value indicating whether the Current Page option button is displayed. It gets or sets a value indicating whether the Print to file check box is enabled. It gets or sets a value indicating whether the Selection option button is enabled. It gets or sets the printer settings the dialog box modifies. It gets or sets a value indicating the PrintDocument used to obtain PrinterSettings. It gets or sets a value indicating whether the Print to file check box is selected. It gets or sets a value indicating whether the Help button is displayed. Resets all options to their default values. When overridden in a derived class, specifies a common dialog box. Runs a common dialog box with a default owner Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintDialog1.Document = PrintDocument1 PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings PrintDialog1.AllowSomePages = True If PrintDialog1.ShowDialog = DialogResult.OK Then PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings PrintDocument1.Print() End If 6 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Sub Procedures and functions A procedure is a group of statements that together perform a task when called. After the procedure is executed, the control returns to the statement calling the procedure. VB.Net has two types of procedures: o Functions o Sub procedures or Subs Functions (Defining a Function) o The Function statement is used to declare the name, parameter and the body of a function. o Functions return a value, whereas Subs do not return a value. o The syntax for the Function statement is: [Modifiers] Function FunctionName [ (parameterlist) ] as ReturnType [statements] End Function Modifiers: Specify the access level of the function; possible values are: Public, Private, Protected, Friend, Protected, Friend and information regarding overloading, overriding, sharing, and shadowing. FunctionName: Indicates the name of the function. ParameterList: Specifies the list of the parameters. ReturnType: Specifies the data type of the variable the function returns. Function Returning a Value: o A function can return a value to the calling code in two ways: By using the return statement By assigning the value to the function name 7 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

o In the below example, we write a one function which find out the maximum number from a given two numbers and the return type of that function is Integer. Module Module1 Function max_number(byval number1 As Integer, ByVal number2 As Integer) As Integer Dim result As Integer If (number1 > number2) Then result = number1 Else result = number2 End If Return result 'By using the return statement 'max_number = result 'By assigning the value to the function name End Function Sub Main() Dim ans As Integer = max_number(1, 7) Console.Write("Maximum Number is : {0}", ans) Console.ReadKey() End Module Maximum Number is : 7 Sub Procedures or Subs o Sub procedures are procedures that do not return any value. We have been using the Sub procedure Main in all our examples. o When console applications start, the control goes to the Main Sub procedure, and it in turn, runs any other statements constituting the body of the program. Defining a Sub Procedures: o The Sub statement is used to declare the name, parameter and the body of a sub procedure. The syntax for the Sub statement is: [Modifiers] Sub subname [parameterlist] [statements] Modifiers: specify the access level of the procedure; possible values are: Public, Private, Protected, Friend, Protected, Friend and information regarding overloading, overriding, sharing, and shadowing. SubName: indicates the name of the Sub. ParameterList: specifies the list of the parameters. 8 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Module Module1 Sub Simple() Console.WriteLine("Simple Non Parameterized Procedure") Console.WriteLine() Sub Addition(ByVal number1 As Integer, ByVal number2 As Integer) Dim ans As Integer = number1 + number2 Console.WriteLine("Addition of 5 and 3 is {0}", ans) Sub Main() Simple() Addition(5, 3) Console.ReadKey() End Module Simple Non Parameterized Procedure Addition of 5 and 3 is 8 o As shown in the above example, we created a one sub procedure named Addition which takes two integer parameters and we also created another Sub Procedure called Simple which has no parameter. Pass by value o In this mechanism, when a method is called, a new storage location is created for each value parameter. o The values of the actual parameters are copied into them. So, the changes made to the parameter inside the method have no effect on the argument. o In VB.Net, you declare the reference parameters using the ByVal keyword. The following example demonstrates the concept of pass by value in which we swap the value of two variables: Module Module1 Sub swap(byval x As Integer, ByVal y As Integer) Dim temp As Integer temp = x x = y y = temp Sub Main() 9 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Dim a As Integer = 11 Dim b As Integer = 22 Console.WriteLine("Before swap, value of a : {0}", a) Console.WriteLine("Before swap, value of b : {0}", b) swap(a, b) Console.WriteLine() Console.WriteLine("After swap, value of a : {0}", a) Console.WriteLine("After swap, value of b : {0}", b) Console.ReadLine() End Module Before swap, value of a : 11 Before swap, value of b : 22 After swap, value of a : 11 After swap, value of b : 22 o The above example shows that there is no change in the values even if they had been changed inside the function. Passing Parameters by Reference o A reference parameter is a reference to a memory location of a variable. o When you pass parameters by reference, unlike value parameters, a new storage location is not created for these parameters. o The reference parameters represent the same memory location as the actual parameters that are supplied to the method. o In VB.Net, you declare the reference parameters using the ByRef keyword. The following example demonstrates the concept of pass by reference in which we swap the value of two variables. Module Module1 Sub swap(byref x As Integer, ByRef y As Integer) Dim temp As Integer temp = x x = y y = temp Sub Main() Dim a As Integer = 11 Dim b As Integer = 22 10 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Console.WriteLine("Before swap, value of a : {0}", a) Console.WriteLine("Before swap, value of b : {0}", b) swap(a, b) Console.WriteLine() Console.WriteLine("After swap, value of a : {0}", a) Console.WriteLine("After swap, value of b : {0}", b) Console.ReadLine() End Module Before swap, value of a : 11 Before swap, value of b : 22 After swap, value of a : 22 After swap, value of b : 11 Exception/Error Handling: Structured Error Handling For Error Handling VB.Net provides Exception Handling, an exception is a problem that arises during the execution of a program. An exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. VB.Net exception handling is built upon four keywords: Try, Catch, Finally and Throw. o Try: A Try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more Catch blocks. o Catch: A program catches an exception with an exception handler at the place in a program where you want to handle the problem. o Finally: The Finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. o Throw: A program throws an exception when a problem shows up. This is done using a Throw keyword. Syntax of Try/Catch: Try [Statements] Catch ex as [Exception Type] [Statements] Catch ex1 as [Exception Type] [Statements] 11 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Finally [Finally statements] End Try You can list down multiple catch statements to catch different type of exceptions in case your try block raises more than one exception in different situations. The following table provides some of the predefined exception classes derived from the Sytem.SystemException class: Exception Class System.IO.IOException System.IndexOutOfRangeException System.DivideByZeroException System.OutOfMemoryException System.NullReferenceException It handles I/O errors. It handles errors generated when a method refers to an array index out of range. It handles errors generated from dividing a dividend with zero. It handles errors generated from insufficient free memory. It handles errors generated from deferencing a null object. Module exceptionprog Sub division(byval num1 As Integer, ByVal num2 As Integer) Dim result As Integer Try result = num1 / num2 Catch e As DivideByZeroException Console.WriteLine("Exception caught: {0}", e) Finally Console.WriteLine("Result: {0}", result) End Try Sub Main() division(25, 0) Console.ReadKey() End Module Exception caught: System.DivideByZeroException: Attempted to divide by zero. at... Result: 0 12 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Unstructured Error Handling (On error go to line, goto 0, goto -1, resume next ) On Error GoTo statements is used to handling Unstructured Exception. Error GoTo redirect the flow of the program in a given location. Syntax On Error Go: On Error { GoTo [line 0-1 Resume Next } o GoTo line: Enables the error-handling routine that starts at the line specified in the required line argument. The line argument is any line label or line number. If a run-time error occurs, control branches to the specified line, making the error handler active. The specified line must be in the same procedure as the On Error statement, or a compile-time error will occur. o GoTo 0: Disables the enabled error handler in the current procedure and resets it to Nothing. o GoTo -1: Disables the enabled exception in the current procedure and resets it to Nothing. o Resume Next: Specifies that when a run-time error occurs, control goes to the statement immediately following the statement where the error occurred, and execution continues from that point. Use this form rather than On Error GoTo when accessing objects. Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Num1, Num2, Ans As Integer Num1= TextBox1.Text Num2= TextBox2.Text On Error GoTo Handle Ans = Num1 / Num2 MessageBox.Show("Your answer is:" & Ans) On Error GoTo 0 TextBox1.Text = "" TextBox2.Text = "" Handle: If (TypeOf Err.GetException() Is ArithmeticException) Then MsgBox("You can not divide any number with zero!!") Resume Next End If End Class 13 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Multiple document interface (MDI) The multiple-document interface (MDI) allows you to create an application that maintains multiple forms within a single container form. Applications such as Microsoft Excel and Microsoft Word for Windows have multiple-document interfaces. An MDI application allows the user to display multiple documents at the same time, with each document displayed in its own window. Documents or child windows are contained in a parent window, which provides a workspace for all the child windows in the application. For example, Microsoft Excel allows you to create and display multiple-document windows of different types. Each individual window is confined to the area of the Excel parent window. When you minimize Excel, all of the document windows are minimized as well, only the parent window's icon appears in the task bar. A child form is an ordinary form that has its MDIChild property set to True. Your application can include many MDI child forms of similar or different types. Following below are the steps to create MDI parent form in vb.net application: o Open visual studio then Go to and create a new window application Give proper title MDI_Example Click OK button. o After that click on the Solution explorer and right click on the application name Select Add option from the opened context menu Select New Item (See Fig 4.1). It will open a one dialog box (See Fig 4.2) o From opened dialog box, Select Windows Form category from left side in opened dialog box select MDI Parent Form (give proper name of the MDI Form) Click on the ADD button. (See Fig 4.2) o Select the MDI form and set the following properties of the MDI form. IsMdiContainer = True WindowState = Maximize o Now set your MDI form as a startup form in your application, Do the following steps: 14 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Go to Solution Explorer and select your application name. Right click on it and select properties from the opened context menu. It will open one dialog box which shown in Fig 4.3. Select application tab from the opened dialog box and set your MDI form as Startup form which is shown in Fig 4.3. Fig 4.1 add new Item in application Fig 4.2 Add New Item Dialog Box Fig 4.3 Set MDI form as startup Form Following below are the steps to create MDI Child form in vb.net application: o Create a MDI parent form with a MenuStrip which containing the values New and Windows as menu items and also create an Open as sub menu of New.(See Fig 4.4) 15 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura

Fig 4.4 MDI Form with MenuStrip Control o After that click on the Solution explorer and right click on the application name Select Add option from the opened context menu Select New Item. It will open a one dialog box (See Fig 4.2) o From opened dialog box, Select Windows Form category from left side in opened dialog box select Windows Form Click on the ADD button (See Fig 4.2). o After that drag and drop a RichTextBox Control to the newly created Form from Toolbox. o After that double click on the submenu Open from MDI form and write the following code to add the Child form under this MDI form. Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim ChildForm As Form1 = New Form1() ChildForm.MdiParent = Me ChildForm.WindowState = FormWindowState.Normal ChildForm.Show() o Now run the application, and then you can create a new MDI child form by clicking on Open Submenu Item. When you click on the Open submenu, it will open childform within the MDI parent form which shown in Fig 4.5. Fig 4.5 ChildForm within MDI parent form 16 Dept: CE.NET Programming (3340704) Prof. Akash N. Siddhpura