Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.

Similar presentations


Presentation on theme: "CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications."— Presentation transcript:

1 CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications

2 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 2 Chapter Introduction The Integrated Development Environment (IDE) is used for modern software development. The IDE contains tools to write code, build a GUI, and test and debug applications. Overview of the application construction process. Design issues are addressed. Visual Basic.NET controls are examined. The MsgBox statement and InputBox() function are visited. A project is developed as a working application.

3 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 3 Objectives Design and construct simple complete applications from scratch. Explain the structure of Visual Basic.NET. List the characteristics of several Visual Basic.NET controls. Identify the purpose of each major control of the Visual Basic.NET IDE. Explain basic programming practices that contribute to the readability of programs.

4 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 4 2.1 From New Solution to Finished Application Overview of the Construction Process –Visual Basic.NET runs under Windows. –The programmer creates the application. –The project is an application under construction. –The application is saved to disk periodically. –An executable file is generated from the finished application program.

5 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 5 Visual Basic.NET’s Three Modes Design Mode –Placing, arranging, and customizing the appearance of buttons, labels, and other controls on a form. –Writing processing scripts (source code). –Saving the solution. –Making an executable file.

6 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 6 Visual Basic.NET’s Three Modes (cont.) Run Mode –Executes the solution. –Used to evaluate the workability of a part of the project. –Used to show the user how the solution will work.

7 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 7 Visual Basic.NET’s Three Modes (cont.) Break Mode –Helps the developer with debugging. –Enables the developer to switch back to run mode or design mode.

8 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 8 Design Time and Run Time In design mode, the project is in design time. In run mode, the project is in run time. Some errors can be found and corrected in design time. Other errors can only be detected during run time.

9 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 9 2.2 Overview of Controls Standard controls are used to create user- friendly applications. Standard controls help users lower the learning curve for new programs.

10 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 10 Categories of Controls Trigger: Initiate processing –Ex. Button, MainMenu, and Timer Input: Get data from user –Ex. TextBox, RadioButton, and CheckBox Output: Display results to user –Ex. Label, DataGrid, and ListView

11 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 11 Categories of Controls (cont.) Organize: Group other controls –Ex. Form, GroupBox, and Panel Data Access: Interface with databases –Ex. Entire Data Group and DataGrid

12 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 12 2.3 The Visual Basic.NET Development Environment The IDE helps develops create efficient and effective solutions. The IDE for Visual Basic.NET is common to all the other tools available in the Visual Studio. NET suite.

13 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 13 Getting Started Open an existing project or begin a new project from the Start Page. Use the My Profile option to set up the IDE.

14 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 14 Visual Basic.NET Solution Structure Every application will be organized as a “solution.” Solution Explorer is an interface for viewing and managing containers and associated items. Items are files that make up your project, such as forms, source files, and classes.

15 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 15 Main Tools Used in VB.NET Menu Toolbar Solution Explorer Properties Editor Tasklist Toolbox Designer Window

16 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 16 Saving a Solution Save your solution and all its contents on a regular basis. Each project should be in its own separate folder. Avoid the temptation to use the Save As…, save option. Use the Save and Save All Toolbar icons.

17 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 17 Summary Many of the features of the Visual Basic.NET IDE have been introduced. Next, some of the controls to write simple programs will be introduced. Experimentation is encouraged. Hands-on experience is important.

18 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 18 2.4 Introducing the Windows Form Control The window that is displayed when the application is running. The IDE automatically creates a Windows Form when you start a new project. This form will hold or “contain” other controls.

19 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 19 2.5 The Button Control React to the click of the use Perform a task associated with the name of the button that is displayed on its face. button control

20 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 20 Appearance and Use Appears as a rectangular-shaped control on a form. Its face can display text, an image, or both. The face of the button should clearly indicate its function.

21 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 21 Button Properties The most common properties of the Button control are listed. –Name –Enabled –Font –ForeColor –TabIndex –TabStop –Text –Visible Most properties are available for every control.

22 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 22 Events Components are able to respond to events. The click event is generated when the user clicks the mouse button. You write code to handle events. Double-click the Button control to automatically open the code window.

23 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 23 2.6 The Label Control Used to display information to the user. Used to label other controls or show results of a calculation. –Ex. Check box and radio button labels. label control

24 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 24 Appearance and Use Appears as a rectangular area that can be filled with text. You have some control over size and alignment of text. You can include a border around the label.

25 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 25 Label Properties Many of the Button control properties apply to the Label control. Some others are: –AutoSize –BorderStyle –UseMnemonic The Text Property is the most-used property for the Label control.

26 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 26 Events Example 2.1 Using the Label Control –Demonstrates two main uses of the Label control To display a message to the user. To display “labeling” information for the user.

27 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 27 2.7 The TextBox Control Provides an area for the user to type while the program runs. textbox control

28 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 28 Appearance and Use Displays as a rectangular area that provides the user a place to type. You can limit the user types You can also surround the TextBox with a border.

29 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 29 Textbox Properties Some of the TextBox control properties are only available at run time. The value of the Text property is used most frequently. Control of user entry is shared between properties and events.

30 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 30 Properties (cont.) The PasswordChar property allows you to set a security character. TextLength property determines the number of characters contained in a textbox. Selection … properties provide information on user selections in the TextBox control.

31 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 31 Common Textbox Properties AcceptsReturn AcceptsTab MaxLength Multiline PasswordChar ReadOnly ScrollBars SelectedText SelectionLength SelectionStart TextLength WordWrap

32 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 32 Events Focus means the user is currently working with the specific control. Enter - Occurs when input focus is received. KeyPress - Occurs when a key is pressed while the control has focus. Leave – Occurs when input focus leaves the control.

33 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 33 Events (cont.) Methods –Enable the developer to manipulate text in a TextBox. –Many are available to the developer.

34 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 34 Common Events for the TextBox Control Enter KeyPress Leave AppendText Clear Copy Cut Paste Select SelectAll Undo

35 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 35 2.8 The MsgBox Statement and InputBox Function Two alternate ways to receive information from the user and to display information on the screen.

36 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 36 MsgBox Statement The MsgBox statement will display information that requires user intervention. –MsgBox(“A prompt”, Buttons,”A title”) –MsgBox(“Bad Problem – Bummer”, MsgBoxStyle.Critical + MsgBoxStyle.AbortRetryCancel,”Error Detected”) critical icon

37 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 37 InputBox() Function The InputBox() function requests information from the user with a dialog box. It requires user intervention. –InputBox(“A prompt”,”A title”,”A default response”) –lblInfo.Text = InputBox(“What’s your name?”,”Get Name”,”John Doe”) default response

38 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 38 Quick Review An application being developed in Visual Basic.NET is called a project. What are the three modes of operation used by Visual Basic.NET? What are some of the Visual Basic.NET IDE development tools? What would a proper name be for a button control that is used to cancel the current action and close the screen?

39 ©2002 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin 2- 39 Quick Review (cont.) Name a Windows control used to contain the other GUI controls. Name a control which enables the user to trigger a process by a click event. What VB statement provides an alternate means to provide information to the user? What VB function provides an alternate way to receive information from the user?


Download ppt "CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications."

Similar presentations


Ads by Google