Visual Basic Tutorial Lesson 37: Adding Menus for Your Application #free #visual

#

Lesson 37: Creating Menus for Your Applications

The menu bar is the standard feature of most Windows applications. The main purpose of the menus is for easy navigation and control of an application. Some of the most common menu items are File, Edit, View, Tools, Help and more. Each item on the main menu bar also provides a list of options in the form of a pull-down menu. When you create a Visual Basic 6 program, you need not include as many menu items as a full-fledged Windows application. What you need is to include those menu items that can improve the ease of usage by the user. There are two ways to add menus to your application, using the Visual Basic’s Application Wizard and or the menu editor.

37.1 Adding Menu Bar Using Visual Basic’s Application Wizard

The easiest way to add a menu bar to your application is by using Visual Basic’s Application Wizard. This wizard allows the user to insert fully customized standard Windows menu into his or her application. To start using Visual Basic’s Application Wizard, click on the Application Wizard icon at the Visual Basic new project dialog box, as shown in Figure 37.1 below:

Figure 37.1: New Project Window

When you click on the VB Application wizard, the introduction dialog box will appear, as shown in Figure 37.2. As you are not loading any default setting, just click on the Next button.

Figure 37.2

After clicking the Next button, the interface type dialog box will be displayed, as shown in Figure 37.3. There are three choices of interface available for your project. As we currently not creating a Multiple Document Interface (MDI), we choose Single Document Interface (SDI). You can also type the project name in the textbox below, here I am using MyFirstMenu.

Figure 37.3

Clicking the Next button wiill bring up a list of menus and submenus that you can add them to your application. Check to select a menu item and uncheck to unselect a menu item as shown in Figure 37.4. Let say we choose all the menus and click next, then you will get an interface comprises File, Edit, View and Help menus, as shown in Figure 37.5

Figure 37.4

Figure 37.5

When you click on any menu item, a list of drop-down submenu items will be displayed. For example, if you click on the File menu, the list of submenu items such as New, Open, Save, Save As and more will be displayed, as shown in Figure 37.6

Figure 37.6

Clicking on any of the dropped down menu item will show the code associated with it, and this is where you can modify the code to suit your programming needs. For example, clicking on the item Open will reveal the following code:

Figure 37.7

Now, I will show you how to modify the code in order to open a graphic file and display it in an image box. For this program, you have to insert a Image box into the form. Next add the following lines so that the user can open graphic files of different formats.

Filter = Bitmaps(*.BMP)|*.BMP|Metafiles(*.WMF)|*. WMF|Jpeg Files(*.jpg)|*.jpg|GIF Files(*.gif)|*.gif|Icon Files(*.ico)|*.ico|All Files(*.*)|*.* .

Then, you need to load the image into the Image box with the following code:

Also set the Stretch property of the Image box to true so that the image loaded can resize by itself. Please note that each menu item is a special control, so it has a name too. The name for the menu File in this example is mnuFileOpen.

The Code

When you run the program and click on the File menu and then the submenu Open, the following Open dialog box will be displayed, where you can look for graphic files of various formats to load it into the image box.

Figure 37.8

For example, selecting the jpeg file will allow you to choose the images of jpeg format, as shown in Figure 37.9.

Figure 37.9

Clicking on the particular picture will load it into the image box, as shown in Figure 36.10 below

Figure 37.10

37.2: Adding Menu Bar Using Menu Editor

To start adding menu items to your application, open an existing project or start a new project, then click on Tools in the menu bar of the Visual Basic IDE and select Menu Editor. When you click on the Menu Editor, the Menu Editor dialog will appear. In the Menu Editor dialog. key in the first item File in the caption text box. You can use the ampersand ( ) sign in front of F so that F will be underlined when it appears in the menu, and F will become the hot key to initiate the action under this item by pressing the Alt key and the letter F. After typing File in the Caption text box, move to the name textbox to enter the name for this menu item, you can type in mnuFile here. Now, click the Next button and the menu item File will move into the empty space below, as shown in Figure 37.11:

Figure 37.11

You can then add in other menu items on the menu bar by following the same procedure, as shown in Figure 37.12 below:

Figure 37.12

When you click Ok, the menu items will be shown on the menu bar of the form.

Figure 37.13

Now, you may proceed to add the sub menus. In the Menu Editor, click on the Insert button between File and Exit and then click the right arrow key, and the dotted line will appear. This shows the second level of the menu, or the submenu. Now key in the caption and the name. Repeat the same procedure to add other submenu items. Here, we are adding New, Open, Save, Save As and Exit.

Figure 37.14

Now click the OK button and go back to your form. You can see the dropped down submenus when you click on the item File, as shown.

Figure 37.15

Finally, you can enter the code by clicking on any of the submenu items.





Visual Basic Tutorial – Learn VB Programming with source code #visual #basic,

#

Visual Basic Tutorial – Learn Visual Basic – Online VB Training

Browse Visual Basic tutorials

Visual Basic (VB) is an ideal programming language for developing sophisticated professional applications for Microsoft Windows. It makes use of Graphical User Interface for creating robust and powerful applications. The Graphical User Interface as the name suggests, uses illustrations for text, which enable users to interact with an application. This feature makes it easier to comprehend things in a quicker and easier way.

Coding in GUI environment is quite a transition to traditional, linear programming methods where the user is guided through a linear path of execution and is limited to small set of operations. In GUI environment, the number of options open to the user is much greater, allowing more freedom to the user and developer. Features such as easier comprehension, user-friendliness, faster application development and many other aspects such as introduction to ActiveX technology and Internet features make Visual Basic an interesting tool to work with.

Visual Basic (VB) was developed from the BASIC programming language. In the 1970s, Microsoft started developing ROM-based interpreted BASIC for the early microp roces sor-based computers. In 1982, Microsoft QuickBasic revolutionized Basic and was legitimized as a serious development language for MS-DOS environment. Later on, Microsoft Corporation created the enhanced version of BASIC called Visual Basic for Windows.

Visual Basic (VB) is an event-driven programming language. This is called because programming is done in a graphical environment unlike the previous version BASIC where programming is done in a text only environment and executed sequentially in order to control the user interface. Visual Basic enables the user to design the user interface quickly by drawing and arranging the user elements. Due to this spent time is saved for the repetitive task.

Important Features of Visual Basic (VB)

  • Full set of objects – you ‘draw’ the application
  • Lots of icons and pictures for your use
  • Response to mouse and keyboard actions
  • Clipboard and printer access
  • Full array of mathematical, string handling, and graphics functions
  • Can handle fixed and dynamic variable and control arrays
  • Sequential and random access file support
  • Useful debugger and error-handling facilities
  • Powerful database access tools
  • ActiveX support
  • Package Deployment Wizard makes distributing your applications simple

Visual Basic 6 vs Previous versions of Visual Basic

The original Visual Basic for DOS and Visual Basic For Windows were introduced in 1991.

Visual Basic 3.0 (a vast improvement over previous versions) was released in 1993.

Visual Basic 4.0 released in late 1995 (added 32 bit application support).

Visual Basic 5.0 released in late 1996. New environment, supported creation of ActiveX controls, deleted 16 bit application support.

Visual Basic 6.0 – released in mid 1998s – some identified new features of Visual Basic 6.0:

  • Faster compiler
  • New ActiveX data control object
  • Allows database integration with wide variety of applications
  • New data report designer
  • New Package Deployment Wizard
  • Additional internet capabilities.

If you ever used Visual Basic 3, you too could have known everything. Visual Basic 3 was a reasonably small but powerful language. Visual Basic 4 added classes to the language and made Visual Basic much more complicated. Versions 4, 5, and 6 added more support for database programming and other topics such as custom controls, but Visual Basic was still a fairly understandable language, and if you took the time you could become an expert in just about all of it.

Visual Basic.NET accelerated the expansion of Visual Basic tremendously. The .NET Framework added powerful new tools to Visual Basic, but those tools came at the cost of increased complexity. Associated technologies have been added to the language at an ever – increasing rate, so, today, it is impossible for anyone to be an expert on every topic that deals with Visual Basic.

System requirements for Visual Basic depends on the version of Visual basic software. Visual Basic 6 for windows requires at least Microsoft Windows 95/Windows NT 3.51, 486 processor and a minimum of 16 MB of RAM. A complete installation of the most powerful version of Visual Basic 6.0, the Enterprise Edition, requires more than 250 MB of Hard Disk space.

Freetutes.com has Visual Basic Tutorials explained with examples and source code. This online Visual Basic tutorials are intended for programmers of all levels. Whether you are a beginner or and advanced VB learner you are absolutely here at the right place to learn what you really should learn. (You will currently find only Visual Basic 6 tutorials. We are working on to provide you with Visual Basic.NET tutorials and more other IT related tutorials covering programming, databases, networking, web development etc. Check back now and then for updated and new lessons from Freetutes.com)

Visual Basic Tutorials List:

Learn Visual Basic 6.0 ( VB6 Beginners tutorial ) – A comprehensive Visual Basic 6 starter kit for beginners to Visual basic programming. If you are new to programming or to visual basic this, beginner level tutorial will be the definite guide which you really should go through. Step by step lessons with examples and source code will help you to understand the lessons easily and quickly. Click here to view the table of contents of VB6 for beginners.

Learn Advanced Visual basic 6.0( Advanced VB6 tutorial ) – If you already have a basic knowledge in Visual Basic 6 programming then you can enhance your Visual Basic knowledge by learning more in-depth topics from this Advanced Visual Basic 6 tutorial . This tutorial conducts you on a self-guided tour of all the areas covered by the VB6 Distributed Applications and the VB6 Desktop Applications and teaches you the specific skills you need to achieve in such area. Click here to view the table of contents of Advanced VB6 tutorial

Learn Visual Basic .NET – Visual Basic .NET came out after VB6. If you’re just getting started with programming, VB .NET is a great language to start with. This VB .NET tutorial set will help you to learn programming in a series of simple tutorials written in plain English with absolutely no jargon.

Other Tutorials by Freetutes.com

Learn Systems Analysis – This tutorial is for beginners to Systems Analysis and Design (SAD) Process. If you are new to computers and want to acquire knowledge about the process of system development, then you will find useful information in this tutorial. This tutorial is designed to explain various aspects of software development and different techniques used for building the system. This tutorial is a good introductory guide to the need and overall features of software engineering.