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 Creating a Windows-Based Application in Visual Basic.NET Lesson A

3 Tutorial 1: An Introduction to Visual Basic.NET3 Lesson A Objectives After completing this lesson, you will be able to:  Start and customize Visual Studio.NET  Create a Visual Studio.NET solution  Add a Visual Basic.NET project to a solution  Set the properties of an object  Save a solution, project, and form  Close a solution  Open an existing solution

4 Tutorial 1: An Introduction to Visual Basic.NET4 Starting and Customizing Visual Studio.NET  Visual Studio.NET is Microsoft’s newest integrated development environment (IDE)  Includes programming languages such as Visual Basic.NET, C++.NET, and C#.NET  A Windows-based application has a Windows user interface and runs on a desktop computer  A user interface is what you see and interact with when using an application  A Web-based application, on the other hand, has a Web user interface and runs on a server

5 Tutorial 1: An Introduction to Visual Basic.NET5 The Visual Studio.NET Start Page Links

6 Tutorial 1: An Introduction to Visual Basic.NET6 Visual Studio.NET Recent Projects Solution Explorer Dynamic Help Toolbox

7 Tutorial 1: An Introduction to Visual Basic.NET7 Starting a New Project Installed.NET Products Type of Project Name and Location Of Project Name of Project

8 Tutorial 1: An Introduction to Visual Basic.NET8 Purpose of the Links Included on the Start Page LinkPurpose Get StartedCreate new projects and open existing projects What’s NewAccess information about the new features in Visual Studio.NET and check for Visual Studio.NET updates Online CommunityContact fellow developers online HeadlinesView links to the latest news from the MSDN Online Library, including information on seminars, trade shows, and conferences, as well as training opportunities offered by Microsoft Search OnlineSearch the MSDN Online Library DownloadsAccess the latest product updates and sample code available for download XML Web ServicesSearch for XML Web Services to include in your applications, and publish your own XML Web services Web HostingPost Web applications, for a fee, on servers provided by third- party Internet Service Providers My ProfileCustomize various program settings in the IDE

9 Tutorial 1: An Introduction to Visual Basic.NET9 Visual Basic.NET Project information Properties window Toolbox (auto- hidden) Windows Form object

10 Tutorial 1: An Introduction to Visual Basic.NET10 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

11 Tutorial 1: An Introduction to Visual Basic.NET11 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

12 Tutorial 1: An Introduction to Visual Basic.NET12 The Toolbox Window  The Toolbox window, or toolbox, contains the tools and other components you use when designing a user interface  The contents of the toolbox vary depending on the designer in use

13 Tutorial 1: An Introduction to Visual Basic.NET13 The Windows Form Tab The Windows Form tab  Contains the tools you use when designing your user interface  Contains 47 basic tools  However, 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, with the most used tools listed first

14 Tutorial 1: An Introduction to Visual Basic.NET14 Using the Label Tool  The tools in the toolbox allow you to create objects, called controls, that can be displayed on a form  You use the Label tool to create a label control  The purpose of a label control is to display text that the user is not allowed to edit while the application is running  Assigning meaningful names to the controls on a form will help you keep track of the various controls in the user interface

15 Tutorial 1: An Introduction to Visual Basic.NET15 Using the Label Tool  Used to display data that users cannot change 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

16 Tutorial 1: An Introduction to Visual Basic.NET16 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

17 Tutorial 1: An Introduction to Visual Basic.NET17 Changing the Property for More Than One Control at a Time  You can use the Font property to change the appearance of many of the objects in your user interface  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

18 Tutorial 1: An Introduction to Visual Basic.NET18 Fonts  A font is the general shape of the characters in the text  Courier, Tahoma, and Microsoft Sans Serif  Font styles include regular, bold, and italic

19 Tutorial 1: An Introduction to Visual Basic.NET19 Changing the Property for More Than One Control at a Time  The numbers 8, 10, and 18 are examples of font sizes, which typically are measured in points, with one point equaling 1/72 of an inch  One reason for changing a font is to bring attention to a specific part of the screen  You can change the font size for both controls 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

20 Tutorial 1: An Introduction to Visual Basic.NET20 Changing the Property for More Than One Control at a Time  You can use the Control+Click method to select as many controls as you want  To cancel the selection of one of the selected controls, press and hold down the Control key as you click the control  To cancel the selection of all of the selected controls, release the Control key, then click the form or an unselected control on the form

21 Tutorial 1: An Introduction to Visual Basic.NET21 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 Format menu also has a Center in Form option that centers one or more controls either horizontally or vertically on the form

22 Tutorial 1: An Introduction to Visual Basic.NET22 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

23 Tutorial 1: An Introduction to Visual Basic.NET23 Using the Button Tool  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  In Windows applications, a button control performs an immediate action when clicked  You create a button using the Button tool in the toolbox

24 Tutorial 1: An Introduction to Visual Basic.NET24 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 a file that can be run outside of the Visual Studio.NET IDE  The file, referred to as an executable file, has the same name as the project, but with an.exe filename extension

25 Tutorial 1: An Introduction to Visual Basic.NET25 Writing Visual Basic.NET Code  Actions—such as clicking, double-clicking, and scrolling—are called events  The set of Visual Basic.NET instructions, or code, that tells an object how to respond to an event is called an event procedure  A class definition is simply a block of code that specifies (or defines) the attributes and behaviors of an object  When you start the application, Visual Basic.NET uses the class definition to create the object

26 Tutorial 1: An Introduction to Visual Basic.NET26 Writing Visual Basic.NET 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  You use the Class Name and Method Name list boxes to select the object and event, respectively, that you want to code  To help you follow the rules of the Visual Basic.NET programming language, called syntax, the Code Editor provides you with a code template for every event procedure

27 Tutorial 1: An Introduction to Visual Basic.NET27 Writing Visual Basic.NET Code  The first line in the Code template is called the procedure header  And the last line is called the procedure footer  A keyword is a word that has a special meaning in a programming language  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 Private keyword indicates that the procedure can be used only within the class in which it is defined

28 Tutorial 1: An Introduction to Visual Basic.NET28 Writing Visual Basic.NET Code  The items within the parentheses are called parameters and represent information that is passed to the procedure when it is invoked  If you are using a color monitor, the keywords in the code appear in a different color from the rest of the code  A method is simply a predefined Visual Basic.NET procedure that you can call (or invoke) when needed  When you call the Me.Close method, Visual Basic.NET terminates the current application

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

30 Tutorial 1: An Introduction to Visual Basic.NET30 The 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

31 Tutorial 1: An Introduction to Visual Basic.NET31 The Event Procedure Private Sub ExitButton_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles ExitButton.Click Me.Close() End Sub

32 Tutorial 1: An Introduction to Visual Basic.NET32 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

33 Tutorial 1: An Introduction to Visual Basic.NET33 Using the Timer Tool  Splash screens typically do not contain an Exit button; rather, they use a timer control to automatically remove the splash screen after a set period of time  You create a timer control using the Timer tool in the toolbox  You can use a timer control to process code at regular time intervals  You simply set the control’s Interval property to the length of the desired time interval, in milliseconds

34 Tutorial 1: An Introduction to Visual Basic.NET34 Using the Timer Tool  You also set its Enabled property to True  The Enabled property determines whether an object can respond to an event  You then enter the code you want processed into the control’s Tick event procedure  The Tick event procedure tells the computer what to do after each time interval has elapsed  Now that you have a timer control on the form, you no longer need the Exit button, so you can delete it and its associated code

35 Tutorial 1: An Introduction to Visual Basic.NET35 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

36 Tutorial 1: An Introduction to Visual Basic.NET36 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  Unlike most applications, splash screens typically do not contain a title bar  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

37 Tutorial 1: An Introduction to Visual Basic.NET37 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