
Beginning Visual Basic 2015
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions

Person
Content
- Intro
- BEGINNING Visual Basic® 2015
- ABOUT THE AUTHOR
- ABOUT THE TECHNICAL EDITOR
- CREDITS
- ACKNOWLEDGMENTS
- CONTENTS
- INTRODUCTION
- CHAPTER 1: WELCOME TO VISUAL BASIC 2015
- Implementing Event-Driven Programming
- Installing Visual Basic 2015
- The Visual Studio 2015 IDE
- The Profile Setup Page
- The Menu
- The Toolbars
- Creating a Simple Application
- Windows in the Visual Studio 2015 IDE
- Modified Hungarian Notation
- The Code Editor
- Using the Help System
- Summary
- CHAPTER 2: THE MICROSOFT .NET FRAMEWORK
- The .NET Vision
- This Sounds Like Java
- Where Now?
- Writing Software for Windows
- The .NET Framework Classes
- Executing Code
- Common Language Runtime
- Code Loading and Execution
- Application Isolation
- Security
- Interoperability
- Exception Handling
- The Common Type System and Common Language Specification
- Summary
- CHAPTER 3: WRITING SOFTWARE
- Information and Data
- Algorithms
- What Is a Programming Language?
- Working with Variables
- Comments and Whitespace
- Comments
- Whitespace
- Data Types
- Working with Numbers
- Common Integer Math Operations
- Integer Math Shorthand
- The Problem with Integer Math
- Floating-Point Math
- Working with Strings
- Using Dates
- Boolean
- Storing Variables
- Binary
- Bits and Bytes
- Representing Values
- Converting Values
- Methods
- Why Use Methods?
- Methods You've Already Seen
- Building a Method
- Choosing Method Names
- Scope
- Summary
- CHAPTER 4: CONTROLLING THE FLOW
- Making Decisions
- The If Statement
- The Else Statement
- Allowing Multiple Alternatives with ElseIf
- Nested If Statements
- Single-Line If Statement
- Comparison Operators
- String Comparison
- Select Case
- Case-Insensitive Select Case
- Multiple Selections
- The Case Else Statement
- Different Data Types with Select Case
- Loops
- The For...Next Loop
- The Do...Loop Loops
- Nested Loops
- Quitting Early
- Quitting Do...Loops
- Infinite Loops
- Summary
- CHAPTER 5: WORKING WITH DATA STRUCTURES
- Understanding Arrays
- Defining and Using Arrays
- Using For Each...Next
- Passing Arrays as Parameters
- Sorting Arrays
- Going Backward
- Initializing Arrays with Values
- Understanding Enumerations
- Using Enumerations
- Determining the State
- Setting Invalid Values
- Understanding Constants
- Using Constants
- Different Constant Types
- Structures
- Building Structures
- Adding Properties to Structures
- Working with ArrayLists
- Using an ArrayList
- Deleting from an ArrayList
- Showing Items in the ArrayList
- Working with Collections
- Creating CustomerCollection
- Adding an Item Property
- Building Lookup Tables with Hashtable
- Using Hashtables
- Cleaning Up: Remove, RemoveAt, and Clear
- Case Sensitivity
- Advanced Array Manipulation
- Dynamic Arrays
- Using Preserve
- Summary
- CHAPTER 6: BUILDING WINDOWS APPLICATIONS
- Responding to Events
- Counting Characters
- Counting Words
- Creating More Complex Applications
- Creating the Toolbar
- Creating the Status Bar
- Creating an Edit Box
- Clearing the Edit Box
- Responding to Toolbar Buttons
- Using Multiple Forms
- About Dialog
- Summary
- CHAPTER 7: DISPLAYING DIALOGS
- The MessageBox
- Available Icons for MessageBox
- Available Buttons for MessageBox
- Setting the Default Button
- Miscellaneous Options
- The Show Method Syntax
- Example Message Boxes
- The OpenFileDialog Control
- The OpenFileDialog Control
- The Properties of OpenFileDialog
- OpenFileDialog Methods
- Using the OpenFileDialog Control
- The SaveDialog Control
- The Properties of SaveFileDialog
- SaveFileDialog Methods
- Using the SaveFileDialog Control
- The FontDialog Control
- The Properties of FontDialog
- The Methods of FontDialog
- Using the FontDialog Control
- The ColorDialog Control
- The Properties of ColorDialog
- Using the ColorDialog Control
- The PrintDialog Control
- The Properties of PrintDialog
- Using the PrintDialog Control
- The PrintDocument Class
- The Properties of the PrintDocument Class
- Printing a Document
- The FolderBrowserDialog Control
- The Properties of FolderBrowserDialog
- Using the FolderBrowserDialog Control
- Summary
- CHAPTER 8: CREATING MENUS
- Understanding Menu Features
- Images
- Access Keys
- Shortcut Keys
- Check Marks
- The Properties Window
- Creating Menus
- Designing the Menus
- Adding Toolbars and Controls
- Coding Menus
- Coding the View Menu and Toolbars
- Testing Your Code
- Context Menus
- Creating Context Menus
- Enabling and Disabling Menu Items and Toolbar Buttons
- Summary
- CHAPTER 9: DEBUGGING AND ERROR HANDLING
- Major Error Types
- Syntax Errors
- Execution Errors
- Logic Errors
- Debugging
- Creating a Sample Project
- Setting Breakpoints
- Debugging Using the Watch Window and QuickWatch Dialog Box
- Debugging with the Autos Window
- Debugging with the Locals Window
- Error Handling
- Using Structured Error Handling
- Summary
- CHAPTER 10: BUILDING OBJECTS
- Understanding Objects
- Encapsulation
- Methods and Properties
- Events
- Visibility
- What Is a Class?
- Building Classes
- Reusability
- Designing an Object
- State
- Behavior
- Storing State
- Real Properties
- Read/Write Properties
- Auto-Implemented Properties
- The IsMoving Method
- Constructors
- Inheritance
- Adding New Methods and Properties
- Adding a GetPowerToWeightRatio Method
- Changing Defaults
- Polymorphism: Scary Word, Simple Concept
- Overriding More Methods
- Inheriting from the Object Class
- Objects and Structures
- The Framework Classes
- Namespaces
- The Imports Statement
- Creating Your Own Namespace
- Inheritance in the .NET Framework
- Summary
- CHAPTER 11: ADVANCED OBJECT-ORIENTED TECHNIQUES
- Building a Favorites Viewer
- Internet Shortcuts and Favorites
- Using Classes
- Scanning Favorites
- Viewing Favorites
- An Alternative Favorite Viewer
- Building a Favorites Tray
- Displaying Favorites
- Using Shared Properties and Methods
- Using Shared Properties
- Using Shared Methods
- Understanding Object-Oriented Programming and Memory Management
- Garbage Collection
- Releasing Resources
- Defragmentation and Compaction
- Summary
- CHAPTER 12: ACCESSING DATA USING STRUCTURED QUERY LANGUAGE
- What You Need to Complete This Chapter's Exercises
- What Is a Database?
- Database Tables
- Primary and Foreign Keys
- Queries
- Understanding Basic SQL Syntax
- Using SELECT Statement
- Using the JOIN Statement
- Using the UPDATE Statement
- Using the DELETE Statement
- Using the INSERT Statement
- Using the SQL Comment
- Executing Queries in SQL Server
- Summary
- CHAPTER 13: DATABASE PROGRAMMING WITH SQL SERVER AND ADO.NET
- ADO.NET
- ADO.NET Data Namespaces
- The SqlConnection Class
- Working with the Connection String Parameters
- Opening and Closing the Connection
- The SqlCommand Class
- The SqlDataAdapter Class
- The DataSet Class
- DataView
- The ADO.NET Classes in Action
- Data Binding
- BindingContext and CurrencyManager
- Binding Controls
- Binding Examples
- Summary
- CHAPTER 14: ASP.NET
- Thin-Client Architecture
- Web Forms versus Windows Forms
- Windows Forms Advantages
- Web Forms Advantages
- Web Applications: The Basic Pieces
- Web Servers
- Browsers
- HyperText Markup Language
- JavaScript
- Cascading Style Sheets
- Active Server Pages
- Benefi ts of ASP.NET Web Pages
- Special Website Files
- Development
- Controls: The Toolbox
- Building Websites
- Creating a Web Form for Client- and Server-Side Processing
- Website Locations with VS 2015
- Performing Data Entry and Validation
- Using the GridView to Build a Data-Driven Web Form
- Summary
- CHAPTER 15: DEPLOYING YOUR APPLICATION
- What Is Deployment?
- ClickOnce Deployment
- XCOPY Deployment
- Visual Studio 2015 Setup Application Options
- Deploying Different Solutions
- Private Assemblies
- Shared Assemblies
- Deploying Desktop Applications
- Deploying Web Applications
- Deploying XML Web Services
- Useful Tools
- Summary
- CHAPTER 16: WINDOWS 8 APPS
- Windows 8 Application Design Principles
- Using Touch
- Application Commands
- Windows 8 Controls
- Coding Windows 8 Apps with XAML
- Creating Your First Windows 8 App
- Application Layout
- Application Views
- Screen Sizes and Orientation
- Summary
- APPENDIX: EXERCISE SOLUTIONS
- INDEX
- ADVERT
- EULA
1
Welcome to Visual Basic 2015
WHAT YOU WILL LEARN IN THIS CHAPTER:
- Using event-driven programming
- Installing Visual Basic 2015
- Touring the Visual Basic 2015 integrated development environment (IDE)
- Creating a simple Windows program
- Using the integrated Help system
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at www.wrox.com/begvisualbasic2015 on the Download Code tab. The code is in the 092117 C01.zip download.
This is an exciting time to enter the world of programming with Visual Basic 2015 and Windows 8 and the new Windows 10. The new Windows operating systems represent the latest from Microsoft and are packed with a lot of new features to make Windows programming fun. Much has changed in the Windows user interface, and Visual Basic 2015 makes it easy to write professional-looking Windows applications as well as web applications and web services. Haven't upgraded to Windows 8 or 10 yet? No worries; Visual Basic 2015 also enables you to write professional-looking applications for previous versions of Windows as well.
The goal of this book is to help you use the Visual Basic 2015 programming language, even if you have never programmed before. You start slowly and build on what you have learned in subsequent chapters. So take a deep breath, let it out slowly, and tell yourself you can do this. No sweat! No kidding!
Programming a computer is a lot like teaching a child to tie his shoes. Until you find the correct way of giving the instructions, not much is accomplished. Visual Basic 2015 is a language you can use to tell your computer how to do things; but like a child, the computer will understand only if you explain things very clearly. If you have never programmed before, this sounds like an arduous task, and sometimes it can be. However, Visual Basic 2015 offers an easy-to-use language to explain some complex tasks. Although it never hurts to have an understanding of what is happening at the lowest levels, Visual Basic 2015 frees the programmer from having to deal with the mundane complexities of writing Windows applications. You are free to concentrate on solving real problems.
Visual Basic 2015 helps you create solutions that run on the Microsoft Windows operating systems, such as Windows 7, 8, or 10, Windows Server 2008, and Windows Phone. If you are looking at this book, you might have already felt the need or desire to create such programs. Even if you have never written a computer program before, as you progress through the Try It Out exercises in this book, you will become familiar with the various aspects of the Visual Basic 2015 language, as well as its foundations in the Microsoft .NET Framework. You will find that it is not nearly as difficult as you imagined. Before you know it, you will feel quite comfortable creating a variety of different types of programs with Visual Basic 2015.
Visual Basic 2015 can also be used to create web applications and web services, as well as mobile applications that can run on Tablet PCs or smartphones. However, you will begin by focusing on Windows applications before extending your boundaries to other platforms.
IMPLEMENTING EVENT-DRIVEN PROGRAMMING
A Windows program is quite different from yesteryear's MS-DOS program. A DOS program follows a relatively strict path from beginning to end. Although this does not necessarily limit the functionality of the program, it does limit the road the user has to take to get to it. A DOS program is like walking down a hallway; to get to the end you have to walk down the entire hallway, passing any obstacles that you may encounter. A DOS program would let you open only certain doors along your stroll.
Windows, on the other hand, opened up the world of event-driven programming. Events in this context include clicking a button, resizing a window, or changing an entry in a text box. The code that you write responds to these events. In terms of the hallway analogy: In a Windows program, to get to the end of the hall you just click the end of the hall. The hallway itself can be ignored. If you get to the end and realize that is not where you wanted to be, you can just set off for the new destination without returning to your starting point. The program reacts to your movements and takes the necessary actions to complete your desired tasks.
Another big advantage in a Windows program is the abstraction of the hardware, which means that Windows takes care of communicating with the hardware for you. You do not need to know the inner workings of every laser printer on the market just to create output. You do not need to study the schematics for graphics cards to write your own game. Windows wraps up this functionality by providing generic routines that communicate with the drivers written by hardware manufacturers. This is probably the main reason why Windows has been so successful. The generic routines are referred to as the Windows application programming interface (API), and most of the classes in the .NET Framework take care of communicating with those APIs.
Before Visual Basic 1 was introduced to the world in 1991, developers had to be well versed in C and C++ programming, as well as the building blocks of the Windows system itself, the Windows API. This complexity meant that only dedicated and properly trained individuals were capable of turning out software that could run on Windows. Visual Basic changed all that, and it has been estimated that there are now as many lines of production code written in Visual Basic as in any other language.
Visual Basic changed the face of Windows programming by removing the complex burden of writing code for the user interface (UI). By allowing programmers to draw their own UI, it freed them to concentrate on the business problems they were trying to solve. When the UI is drawn, the programmer can then add the code to react to events.
Visual Basic has also been extensible from the very beginning. Third-party vendors quickly saw the market for reusable modules to aid developers. These modules, or controls, were originally referred to as VBXs (named after their file extension). Prior to Visual Basic 5, if you did not like the way a button behaved, you could either buy or create your own, but those controls had to be written in C or C++. Database access utilities were some of the first controls available. Version 5 of Visual Basic introduced the concept of ActiveX, which enabled developers to create their own ActiveX controls.
When Microsoft introduced Visual Basic 3, the programming world changed significantly. You could build database applications directly accessible to users (so-called front-end applications) completely with Visual Basic. There was no need to rely on third-party controls. Microsoft accomplished this task with the introduction of Data Access Objects (DAOs), which enabled programmers to manipulate data with the same ease as manipulating the user interface.
Versions 4 and 5 extended the capabilities of version 3 to enable developers to target the new Windows 95 platform. They also made it easier for developers to write code, which could then be manipulated to make it usable to other language developers. Version 6 provided a new way to access databases with the integration of ActiveX Data Objects (ADOs). The ADO feature was developed by Microsoft to aid web developers using Active Server Pages (ASP) to access databases. All the improvements to Visual Basic over the years have ensured its dominant place in the programming world-it helps developers write robust and maintainable applications in record time.
INSTALLING VISUAL BASIC 2015
You may own Visual Basic 2015 in one of the following forms:
- As part of Visual Studio 2015, a suite of tools and languages that also includes C# (pronounced "C-sharp") and Visual C++: The Visual Studio 2015 product line includes Visual Studio Professional Edition or Visual Studio Tools Team Editions. The Team Edition versions come with progressively more tools for building and managing the development of larger, enterprise-wide applications.
- As Visual Basic 2015 Express Edition: This is a free edition for students and beginners, which includes the Visual Basic 2015 language and a smaller set of the tools and features available with Visual Studio 2015.
Both these products enable you to create your own applications for the Windows platform. The installation procedure is straightforward. In fact, the Visual Studio Installer is smart enough to figure out exactly what your computer requires to make it work.
The descriptions in the following Try It Out exercise are based on installing Visual Studio 2015 CTP 6. Most of the installation processes are straightforward, and you can accept the default installation options for most environments. Therefore, regardless of which edition you are installing, the installation process should be smooth when accepting the default installation options.
TRY IT OUT Installing Visual Basic 2015
There are two common ways to install Visual Studio. You can burn a DVD or attach a downloaded image (iso) or use the...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.