Book description
Sometimes you just need to solve a problem and get on with your work. To that end, Visual Basic 2008 Recipes is a compendium of practical solutions for busy VB .NET programmers. Create time for the more interesting aspects of your VB .NET project by solving common problems with the practical solutions and dozens of code examples in this book. Important .NET 3.5 technologies, such as Windows Presentation Framework (WPF) and Language Integrated Query (LINQ), are covered, and each chapter addresses a specific problem domain, including database access, multimedia, XML manipulation, networking, and security. The code is free to download, so you can use the recipes immediately.
Take advantage of quality, ready-made solutions to common Visual Basic programming problems
Avoid the tedium of having to reinvent the wheel-focus instead on the more interesting problems specific to your application
Learn from and be inspired by what the authors have done. Use their work as stepping stones to solve even more complex problems
Table of contents
- Copyright
- Dedication
- About the Author
- About the Technical Reviewer
- Acknowledgments
- Introduction
-
Application Development
- Create a Console Application from the Command Line
- Create a Windows-Based Application from the Command Line
- Create and Use a Code Module from the Command Line
- Create and Use a Code Library from the Command Line
- Embed a Resource File in an Assembly
- Build Projects from the Command Line Using MSBuild.exe
- Access Command-Line Arguments
- Include Code Selectively at Build Time
- Manipulate the Appearance of the Console
- Access a Program Element That Has the Same Name As a Keyword
- Create and Manage Strong-Named Key Pairs
- Give an Assembly a Strong Name
- Verify That a Strong-Named Assembly Has Not Been Modified
- Delay Sign an Assembly
- Sign an Assembly with an Authenticode Digital Signature
- Create and Trust a Test Software Publisher Certificate
- Manage the Global Assembly Cache
- Make Your Assembly More Difficult to Decompile
- Use Implicitly Typed Variables
- Use Object Initializers
- Use Anonymous Types
- Create and Use Extension Methods
- Create and Use Lambda Expressions
-
Data Manipulation
- Manipulate the Contents of a String Efficiently
- Encode a String Using Alternate Character Encoding
- Convert Basic Value Types to Byte Arrays
- Base64 Encode Binary Data
- Validate Input Using Regular Expressions
- Use Compiled Regular Expressions
- Create Dates and Times from Strings
- Add, Subtract, and Compare Dates and Times
- Convert Dates and Times Across Time Zones
- Sort an Array or an ArrayList
- Copy a Collection to an Array
- Manipulate or Evaluate the Contents of an Array
- Use a Strongly Typed Collection
- Create a Generic Type
- Store a Serializable Object to a File
- Read User Input from the Console
-
Application Domains, Reflection, and Metadata
- Load an Assembly into the Current Application Domain
- Create an Application Domain
- Execute an Assembly in a Different Application Domain
- Avoid Loading Unnecessary Assemblies into Application Domains
- Create a Type That Cannot Cross Application Domain Boundaries
- Create a Type That Can Be Passed Across Application Domain Boundaries
- Instantiate a Type in a Different Application Domain
- Pass Data Between Application Domains
- Unload Assemblies and Application Domains
- Retrieve Type Information
- Test an Object's Type
- Instantiate an Object Using Reflection
- Create a Custom Attribute
- Inspect the Attributes of a Program Element Using Reflection
-
Threads, Processes, and Synchronization
- Execute a Method Using the Thread Pool
- Execute a Method Asynchronously
- Creating an Asynchronous Method to Update the User Interface
- Execute a Method Periodically
- Execute a Method at a Specific Time
- Execute a Method by Signaling a WaitHandle Object
- Execute a Method Using a New Thread
- Synchronize the Execution of Multiple Threads Using a Monitor
- Synchronize the Execution of Multiple Threads Using an Event
- Synchronize the Execution of Multiple Threads Using a Mutex
- Synchronize the Execution of Multiple Threads Using a Semaphore
- Synchronize Access to a Shared Data Value
- Know When a Thread Finishes
- Terminate the Execution of a Thread
- Create a Thread-Safe Collection Instance
- Start a New Process
- Terminate a Process
- Ensure That Only One Instance of an Application Can Execute Concurrently
-
Files, Directories, and I/O
- Retrieve Information About a File, Directory, or Drive
- Set File and Directory Attributes
- Copy, Move, or Delete a File or a Directory
- Calculate the Size of a Directory
- Retrieve Version Information for a File
- Show a Just-in-Time Directory Tree in the TreeView Control
- Read and Write a Text File
- Read and Write a Binary File
- Parse a Delimited Text File
- Read a File Asynchronously
- Find Files That Match a Wildcard Expression
- Test Two Files for Equality
- Manipulate Strings Representing File Names
- Determine Whether a Path Is a Directory or a File
- Work with Relative Paths
- Create a Temporary File
- Get the Total Free Space on a Drive
- Show the Common File Dialog Boxes
- Use an Isolated Store
- Monitor the File System for Changes
- Access a COM Port
- Get a Random File Name
- Manipulate the Access Control Lists of a File or Directory
-
Language Integrated Query (LINQ)
- Query a Generic Collection
- Query a Nongeneric Collection
- Control Query Results
- Sort Data Using LINQ
- Filter Data Using LINQ
- Perform General Aggregate Operations
- Perform Average and Sum Calculations
- Perform Count Operations
- Perform Min and Max Calculations
- Group Query Results
- Query Data from Multiple Collections
- Returning Specific Elements of a Collection
- Display Collection Data Using Paging
- Compare and Combine Collections
- Cast a Collection to a Specific Type
-
LINQ to XML and XML Processing
- Create an XML Document
- Load an XML File into Memory
- Insert Elements into an XML Document
- Change the Value of an Element or Attribute
- Remove or Replace Elements or Attributes
- Query an XML Document Using LINQ
- Query for Elements in a Specific XML Namespace
- Query an XML Document Using XPath
- Join and Query Multiple XML Documents
- Convert an XML File to a Delimited File (and Vice Versa)
- Validate an XML Document Against a Schema
- Use XML Serialization with Custom Objects
- Create a Schema for a .NET Class
- Generate a Class from a Schema
- Perform an XSL Transform
-
Database Access
- Connect to a Database
- Use Connection Pooling
- Create a Database Connection String Programmatically
- Store a Database Connection String Securely
- Execute a SQL Command or Stored Procedure
- Use Parameters in a SQL Command or Stored Procedure
- Process the Results of a SQL Query Using a Data Reader
- Obtain an XML Document from a SQL Server Query
- Perform Asynchronous Database Operations Against SQL Server
- Write Database-Independent Code
- Create a Database Object Model
- Generate Data Object Classes from the Command Line
- Discover All Instances of SQL Server on Your Network
-
Windows Forms
- Add a Control Programmatically
- Link Data to a Control
- Process All the Controls on a Form
- Track the Visible Forms in an Application
- Find All MDI Child Forms
- Save Configuration Settings for a Form
- Force a List Box to Scroll to the Most Recently Added Item
- Restrict a Text Box to Accepting Only Specific Input
- Use an Autocomplete Combo Box
- Sort a List View by Any Column
- Lay Out Controls Automatically
- Make a Multilingual Form
- Create a Form That Cannot Be Moved
- Make a Borderless Form Movable
- Create an Animated System Tray Icon
- Validate an Input Control
- Use a Drag-and-Drop Operation
- Use Context-Sensitive Help
- Display a Web Page in a Windows-Based Application
- Create a Windows Presentation Foundation Application
- Run a Windows Vista Application with Elevated Rights
-
Multimedia
- Find All Installed Fonts
- Perform Hit Testing with Shapes
- Create an Irregularly Shaped Control
- Create a Movable Sprite
- Create a Scrollable Image
- Perform a Screen Capture
- Use Double Buffering to Increase Redraw Speed
- Show a Thumbnail for an Image
- Play a Simple Beep or System Sound
- Play a WAV File
- Play a Sound File
- Show a Video with DirectShow
- Retrieve Information About Installed Printers
- Print a Simple Document
- Print a Multipage Document
- Print Wrapped Text
- Show a Dynamic Print Preview
- Manage Print Jobs
-
Networking and Remoting
- Obtain Information About the Local Network Interface
- Detect Changes in Network Connectivity
- Download Data over HTTP or FTP
- Download a File and Process It Using a Stream
- Respond to HTTP Requests from Your Application
- Get an HTML Page from a Site That Requires Authentication
- Send E-mail Using SMTP
- Resolve a Host Name to an IP Address
- Ping an IP Address
- Communicate Using TCP
- Create a Multithreaded TCP Server That Supports Asynchronous Communications
- Communicate Using UDP
- Communicate Using Named Pipes
- Make an Object Remotable
- Register All the Remotable Classes in an Assembly
- Host a Remote Object in IIS
- Control the Lifetime of a Remote Object
- Control Versioning for Remote Objects
- Consume an RSS Feed
-
Security and Cryptography
- Allow Partially Trusted Code to Use Your Strong-Named Assembly
- Disable Execution Permission Checks
- Ensure the Runtime Grants Specific Permissions to Your Assembly
- Limit the Permissions Granted to Your Assembly
- View the Permissions Required by an Assembly
- Determine at Runtime Whether Your Code Has a Specific Permission
- Restrict Who Can Extend Your Classes and Override Class Members
- Inspect an Assembly's Evidence
- Determine Whether the Current User Is a Member of a Specific Windows Group
- Restrict Which Users Can Execute Your Code
- Impersonate a Windows User
- Create a Cryptographically Random Number
- Calculate the Hash Code of a Password
- Calculate the Hash Code of a File
- Verify a Hash Code
- Ensure Data Integrity Using a Keyed Hash Code
- Work with Security-Sensitive Strings in Memory
- Encrypt and Decrypt Data Using the Data Protection API
-
Code Interoperability
- Call a Function in an Unmanaged DLL
- Get the Handle for a Control, Window, or File
- Call an Unmanaged Function That Uses a Structure
- Call an Unmanaged Function That Uses a Callback
- Retrieve Unmanaged Error Information
- Use a COM Component in a .NET Client
- Release a COM Component Quickly
- Use Optional Parameters
- Use an ActiveX Control in a .NET Client
- Expose a .NET Component to COM
- Use a Windows Presentation Foundation Control from a Windows Form
-
Commonly Used Interfaces and Patterns
- Implement a Serializable Type
- Implement a Cloneable Type
- Implement a Comparable Type
- Implement an Enumerable Type Using a Custom Iterator
- Implement a Disposable Class
- Implement a Type That Can Be Formatted
- Implement a Custom Exception Class
- Implement a Custom Event Argument
- Implement the Singleton Pattern
- Implement the Observer Pattern
- Windows Integration
Product information
- Title: Visual Basic 2008 Recipes: A Problem-Solution Approach
- Author(s):
- Release date: April 2008
- Publisher(s): Apress
- ISBN: 9781590599709
You might also like
book
Visual Basic 2005 Cookbook
This book will help you solve more than 300 of the most common and not-so-common tasks …
book
Professional Visual Studio® 2008
Professional Visual Studio 2008 Microsoft Visual Studio 2008 is the latest version in the ongoing evolution …
book
Professional ASP.NET 2.0 Special Edition
ASP.NET allows web sites to display unique pages for each visitor rather than show the same …
book
Applying COM+
COM+ is Microsoft¿s new version of its COM object-oriented programming framework. Built into Windows 2000, this …