Visual Basic Tutorial Adding Form control to Form And Terminating a Program Using Code Adding Controls to a FormNow that you've set the initial properties of your form, it's time to create a user interface by adding objects to the form.Objects that can be placed on a form are called controls. Some controls have a visible interface with which a user can interact, whereas others are always invisible to the user. You'll use controls of both types in this example. On the left side of the screen is a vertical tab titled Toolbox. Click the Toolbox tab to display the Toolbox window, and click the plus sign next to Common Controls to see the most commonly used controls. The toolbox contains all the controls available in the project, such as labels and text boxes.
The toolbox closes as soon as you've added a control to a form and when the pointer is no longer over the toolbox. To
make the toolbox stay visible, you would click the little picture of a pushpin located in the toolbox's title bar. I don't want you to add them yet, but your Picture Viewer interface will consist of the following controls: Two Button controls: The standard buttons that you're used to clicking in pretty much every Windows program you've ever run A PictureBox control: A control used to display images to a user An OpenFileDialog control: A hidden control that exposes the Windows Open File dialog box functionality | ||
Terminating a Program Using CodeThe last bit of code you'll write terminates the application when the user clicks the Quit button. To do this, you'll needto access the Click event handler of the btnQuit button. At the top of the code window are two tabs. The current tab says Viewer Form.vb*. This tab contains the code window for the form that has the file name Viewer Form.vb. Next to this is a tab that says Viewer Form.vb [Design]*. Click this tab to switch from Code view to the form designer. If you receive an error when you click the tab, the code you entered contains an error, and you need to edit it to make it the same as shown: After the form designer appears, double click the Quit button to access its Click event. Enter the following code in the Quit button's Click event handler; press Enter at the end of each statement: ' Close the window and exit the application Me.Close() The Me.Close() statement closes the current form. When the last loaded form in a program is closed, the application shuts itself down completely. As you build more robust applications, you'll probably want to execute all kinds of cleanup routines before terminating an application, but for this example, closing the form is all you need to do. Md. Xamil Hassan toney Next Will will published Data type www.toneysoft.blogspot.com |
Saturday, June 1, 2013
Visual basic tutorial
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment