Presentation on theme: "Creating a Console Application with Visual Studio"— Presentation transcript:
1 Creating a Console Application with Visual Studio Chapter 2Creating a Console Application with Visual Studio
2 Class 2: Visual Studio Visual Studio IDE Create and Compile a Visual Basic projectCreating Application CommentsMy object
3 Introduction to Visual Studio Visual Studio simplifies the process of creating, compiling, and testing applicationsVisual Studio can create applications in Visual C++, C#, J#, and Visual BasicThe same development environment is used regardless of the programming language
4 Visual Studio IDEVisual Studio IDE (integrated development environment)The interface is similar to the interface of other applicationsIt has menus, toolbars, a status bar, and windows with which you develop applicationsFigure 2-1: The Visual Studio IDE
5 Configuring Visual Studio and Help System Options dialog boxHelp SystemNote: Options Dialog Box may appear different from the textbook depending upon the versions and service packs. Yet, the same functions can be found somewhere in the options. I don’t know the incentives of Microsoft engineers who changes those settings.Therefore, I will not go over the details of options and help system as it appears to be impossible to accommodate all the versions. However, the Visual Studio should be configured correctly before creating any applications, and help functions are extremely useful when you encounter a new class or new methods.
6 Object BrowserThe Object Browser is used to examine the types that make up the .NET Framework class library and the types in developer-created applicationsThe Object Browser has a drill-down interfaceThe Object Browser is another kind of help, yet very helpful. When you want to use a method from library class, this will tell you the syntax.
7 Figure 2-22: Object Browser – My Solution Component Selected Do not close object browser using the X mark at the top right corner, it will close the Visual Studio itself. The Object Browser is a tabbed page in the main screen.
8 Types of Visual Studio Applications Templates are used to create different types of applicationsThe supported templates vary based on the installed Visual Studio editionCommon templatesConsole Application projectWindows Application projectClass Library projectASP.NET Web Application projectWeb Service project
9 Introduction to Visual Studio Solutions and Projects A solution is the heart of an applicationA solution contains several folders that define an application’s structureSolution files have a file suffix of .slnA solution contains one or more projectsThe project file is used to create an executable applicationA project file has a suffix of .vbprojProject properties are set using the project's property pages
10 Figure 2-26: Project Property Page – Application tab Project CharacteristicsA project contains one or more namespacesEvery project has one root namespaceEvery project has a type (Console, Windows, etc.)Every project has an entry pointA Sub procedure named Main or a formForms apply only to Windows Application projectsProject ReferencesA project has references to .NET Framework class library namespaces.NET automatically adds references to commonly used namespaces based on the type of project templateUse the References tab of the project property page to add additional namespace references
11 Creating a New Solution Click File, New Project to display the New Project dialog boxSpecify the project template and the project file nameDifferent templates appear based on the installed Visual Studio edition
13 Saving a Visual Studio Project Click File, Save All to save the solution the first timeSpecify the solution name and the folder where the solution will be createdBy default, a new folder is created for a new solutionOrganization of a Visual Studio SolutionThe Solution Explorer is used to manage the elements of a solutionThe folder named My Project contains configuration information common to all projectsThe file AssemblyInfo.vb contains assembly metadataThe References folder contains references to other assembliesThe bin folder contains the executable file produced as a result of compiling the applicationA project contains one or more modules
14 Document WindowsDocument windows are used to edit the files that make up a solutionThe Windows Forms Designer is used to create a form’s visual interfaceThe Code Editor is used to create an application’s codeOther document windows existDocument windows appear on group tabsEach tab is used to edit a particular document
16 Code Editor FeaturesThe Code Editor checks syntax as statements are enteredStatements with syntax errors appear underlinedSyntax errors also appear in the Error List windowThe Code Editor automatically indents statement blocks
17 Using Intellisense with the Code Editor Intellisense technology displays pop-up menus as statements are enteredIntellisense displays classes applicable to a namespaceIntellisense displays members of a class or other typeIntellisense displays arguments to functions or methods
19 Figure 2-37: Code Editor and Error List Window Displaying Syntax Errors
20 Compiling and Executing a Visual Studio Project Clicking Build ProjectName compiles a projectProjectName is a placeholder for the actual project nameVisual Studio calls the same compiler you called directly in Chapter 1Project configuration options are used to set the compiler optionsCompiler output appears in the Output window
21 Executing a Visual Studio Project Pressing F5 builds and runs a projectClicking Debug, Start Debugging builds and runs a projectConsole Application output appears in a Command Prompt window
22 Creating Application Comments Comments document an application’s codeComments are ignored by Visual StudioComments begin with an apostrophe (')Comments can appear alone on a lineComments can appear at the end of a statementThese comments must appear at the end of a lineComments cannot break up a continuation lineWhite space lines do not need a comment character
23 Comments (Best Practices) Create comments when developing or modifying an applicationCreate a comment block at the beginning of a class or module to describe its purposeCreate comment blocks for proceduresDon’t overuse or create unnecessary comments
24 the My Object The My object simplifies programming My.Application gets information about the current applicationMy.Computer gets information about the computerMy.Computer.Network gets information about the networkMy.User gets information about the current user
25 The My.Application Object My.Application.Info has properties to get information about project attributesDescriptionCompanyNameProductNameCopyrightTrademarkVersion
26 The My.Computer ObjectMy.Computer.Info has properties to get information about the computerAvailablePhysicalMemoryAvailableVirtualMemoryTotalPhysicalMemoryTotalVirtualMemoryOSFullNameOSPlatformOSVersion