Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.

Similar presentations


Presentation on theme: "Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET."— Presentation transcript:

1 Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET

2 Tutorial 1: An Introduction to Visual Basic.NET2 Working with Controls Lesson B Objectives After completing this lesson, you will be able to:  Add a control to a form  Set the properties of a label, picture box, and button control  Select multiple controls  Center controls on the form  Set the properties of a project  Start and end an application  Enter code in the Code Editor window  Terminate an application using the Me.Close method

3 Tutorial 1: An Introduction to Visual Basic.NET3 Working With Controls Toolbox ItemDescription DataComponents to access data and data sources ComponentsComponents to perform special tasks Clipboard RingStores items that you have copied GeneralCan be used to store code snippets Windows FormsObjects used to create user interface

4 Tutorial 1: An Introduction to Visual Basic.NET4 The Windows Form Tab The Windows Form tab  Contains the 47 basic tools used to design your user interface  You can add new tools or delete existing tools by right- clicking the tab and then clicking Customize Toolbox on the context menu  By default, the tools on the Windows Form tab are listed in order by their estimated frequency of use, but you can right-click to change this to alphabetic listing

5 Tutorial 1: An Introduction to Visual Basic.NET5 Using the Label Tool  The purpose of a label control is to display text that the user is not allowed to edit while the application is running PropertyDescription NameIdentifies the object in code TextDisplayed information AutoSizeDetermines if the object resizes itself to display all Text LocationSets the X and Y coordinates for where label is displayed FontCharacteristics of the displayed Text

6 Tutorial 1: An Introduction to Visual Basic.NET6 Key Form Properties PropertyDescription NameUsed to refer to the object TextCaption displayed in the title bar StartPositionPosition of window on screen BackgroundImageImage displayed on the form SizeWidth and Height of window LocationLeft and Top position of window

7 Tutorial 1: An Introduction to Visual Basic.NET7 Fonts  The Font property allows you to change the type of font used to display the text in the object, as well as the style and size of the font  Type: Courier, Tahoma, and Microsoft Sans Serif  Style: regular, bold, and italic  Size: The numbers 8, 10, and 18 are examples of font sizes  You can change properties on multiple controls (ex. font size) at the same time by clicking one control and then pressing and holding down the Control key as you click the other control in the form

8 Tutorial 1: An Introduction to Visual Basic.NET8 Using the Format Menu  The Format menu provides options that allow you to manipulate the controls in the user interface  The Align option allows you to align two or more controls by their left, right, top, or bottom borders  You can use the Make Same Size option to make two or more controls the same width or height, or both width and height  The Center in Form option that centers one or more controls either horizontally or vertically on the form

9 Tutorial 1: An Introduction to Visual Basic.NET9 Using the PictureBox Tool  You can include a logo by displaying the logo in a picture box control, which you create using the PictureBox tool

10 Tutorial 1: An Introduction to Visual Basic.NET10 Using the Button Tool – Exit Button  Every Windows application should give the user a way to exit the program  Most Windows applications provide either an Exit option on a File menu or an Exit button for this purpose

11 Tutorial 1: An Introduction to Visual Basic.NET11 Starting and Ending an Application  You can start an application by Clicking Debug on the menu bar, and then clicking Start or you can simply press the F5 key on your keyboard  When you start an application, Visual Studio.NET automatically creates an.exe file which can be run outside of the Visual Studio.NET environment

12 Tutorial 1: An Introduction to Visual Basic.NET12 Visual Basic.NET Code – Classes & Events  When you start the application, Visual Basic.NET uses the class definition to create the object. A class definition is simply a block of code that specifies (or defines) the attributes and behaviors of an object  Actions—such as clicking, double-clicking, and scrolling—are called events

13 Tutorial 1: An Introduction to Visual Basic.NET13 Visual Basic.NET Code – code window  You use the Class Name and Method Name list boxes to select the object and event, respectively, that you want to code  The Class Name list box lists the names of the objects included in the user interface  The Method Name list box, on the other hand, lists the events to which the selected object is capable of responding

14 Tutorial 1: An Introduction to Visual Basic.NET14 Visual Basic.NET Code – code template  The first line in the Code template is called the procedure header  And the last line is called the procedure footer  The Sub keyword is an abbreviation of the term sub procedure, which, in programming terminology, refers to a block of code that performs a specific task  The items within the parentheses are called parameters and represent information that is passed to the procedure when it is invoked

15 Tutorial 1: An Introduction to Visual Basic.NET15 The Code Window Code Editor window tab Class definition Event procedure

16 Tutorial 1: An Introduction to Visual Basic.NET16 ExitButton’s Click Event Procedure Private Sub ExitButton_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles ExitButton.Click Private SubIndicates the start of a code unit that can only be used in this class ExitButton_ClickThe name of the procedures is the object name and event name connected with an underscore sender As ObjectIdentifies the object creating the event e As System.EventArgsIdentifies specific information about the event HandlesIdentifies the object and event that this procedure will handle Note: If you are using a color monitor, the keywords in the code appear in a different color from the rest of the code

17 Tutorial 1: An Introduction to Visual Basic.NET17 The Event Procedure Private Sub ExitButton_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles ExitButton.Click Me.Close() ‘terminates the current application End Sub

18 Tutorial 1: An Introduction to Visual Basic.NET18 Completing the Copyright Screen Lesson C Objectives After completing this lesson, you will be able to:  Set the properties of a timer control  Delete a control from the form  Delete the code from the Code Editor window  Code the timer control’s Tick event  Remove and/or disable the Minimize, Maximize, and Close buttons  Prevent the user from sizing a form  Print the project’s code

19 Tutorial 1: An Introduction to Visual Basic.NET19 Using the Timer Tool  You can use a timer control to process code at regular time intervals when the enabled property is true  You simply set the control’s Interval property to the length of the desired time interval, in milliseconds  The Enabled property determines whether an object can respond to an event  You then enter the code you want processed each time interval into the control’s Tick event procedure

20 Tutorial 1: An Introduction to Visual Basic.NET20 Using the Timer Tool

21 Tutorial 1: An Introduction to Visual Basic.NET21 Setting the FormBorderStyle Property  The FormBorderStyle property determines the border style of a Windows Form object FromBorderStyle setting Description Fixed3DFixed, three-dimensional FixedDialogFixed, thick dialog-style FixedSingleFixed, thin line FixedToolWindowFixed, tool window style NoneNo border SizableSizable, normal style (default) SizableToolWindowSizable, tool window style

22 Tutorial 1: An Introduction to Visual Basic.NET22 The MinimizeBox, MaximizeBox, and ControlBox Properties  You can use a Windows Form object’s MinimizeBox property to disable the Minimize button that appears on the form’s title bar  Similarly, you can use the MaximizeBox property to disable the Maximize button  You can remove the title bar by setting the Windows Forms object’s ControlBox property to False, and then removing the text from its Text property

23 Tutorial 1: An Introduction to Visual Basic.NET23 Printing Your Code  You always should print a copy of the code entered in the Code Editor window, because the printout will help you understand and maintain the application in the future  To print the code, the Code editor window must be the active, or current, window


Download ppt "Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET."

Similar presentations


Ads by Google