Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers
暫譯: Visual Basic 2005 食譜:VB 2005 程式設計師的解決方案
Tim Patrick, John Craig
- 出版商: O'Reilly
- 出版日期: 2006-10-31
- 售價: $1,880
- 貴賓價: 9.5 折 $1,786
- 語言: 英文
- 頁數: 742
- 裝訂: Paperback
- ISBN: 0596101775
- ISBN-13: 9780596101770
-
相關分類:
Visual Basic
已過版
買這商品的人也買了...
-
$480$379 -
$2,030$1,929 -
$580$458 -
$480$379 -
$2,280$2,166 -
$860$679 -
$880$695 -
$650$514 -
$650$507 -
$550$468 -
$980$774 -
$650$507 -
$690$538 -
$720$569 -
$550$429 -
$1,200$948 -
$620$490 -
$350$298 -
$299$236 -
$880$695 -
$1,560$1,326 -
$650$514 -
$290$226 -
$299$236 -
$600$480
相關主題
商品描述
Description
This book will help you solve more than 300 of the most common and not-so-common tasks that working Visual Basic 2005 programmers face every day. If you're a seasoned .NET developer, beginning Visual Basic programmer, or a developer seeking a simple and clear migration path from VB6 to Visual Basic 2005, the Visual Basic 2005 Cookbook delivers a practical collection of problem-solving recipes for a broad range of Visual Basic programming tasks.
The concise solutions and examples in the Visual Basic 2005 Cookbook range from simple tasks to the more complex, organized by the types of problems you need to solve. Nearly every recipe contains a complete, documented code sample showing you how to solve the specific problem, as well as a discussion of how the underlying technology works and that outlines alternatives, limitations, and other considerations. As with all O'Reilly Cookbooks, each recipe helps you quickly understand a problem, learn how to solve it, and anticipate potential tradeoffs or ramifications.
Useful features of the book include:
- Over 300 recipes written in the familiar O'Reilly Problem-Solution-Discussion format
- Hundreds of code snippets, examples, and complete solutions available for download
- VB6 updates to alert VB6 programmers to code-breaking changes in Visual Basic 2005
- Recipes that target Visual Basic 2005 features not included in previous releases
- Code examples covering everyday data manipulation techniques and language fundamentals
- Advanced projects focusing on multimedia and mathematical transformations using linear algebraic methods
- Specialized topics covering files and file systems, printing, and databases
In addition, you'll find chapters on cryptography and compression, graphics, and special programming techniques. Whether you're a beginner or an expert, the Visual Basic 2005 Cookbook is sure to save you time, serving up the code you need, when you need it.
Table of Contents
Preface
1. Visual Basic Programming
1.1 Creating a Windows Forms Application
1.2 Creating a Console Application
1.3 Creating an ASP.NET Web Forms Application
2. The Development Environment
2.1 Discovering and Using a Code Snippet
2.2 Creating a New Snippet
2.3 Sharing Snippets
2.4 Adding Snippet Files to Visual Studio
2.5 Getting an Application's Version Number
2.6 Letting Visual Studio Automatically Update an Application's Version Number
2.7 Setting the Startup Form for an Application
2.8 Setting the Startup to a Sub Main Procedure
2.9 Getting an Application's Command Line
2.10 Testing an Application's Command Line
2.11 Obfuscating an Application
2.12 Determining if an Application Is Running in the Visual Studio Environment
2.13 Accessing Environment Variables
2.14 Accessing the Registry
2.15 Getting System Information
2.16 Getting the User's Name
3. Application Organization
3.1 Creating a Code Module
3.2 Creating a Class
3.3 Creating a Structure
3.4 Creating Other Item Types
3.5 Creating Object Instances
3.6 Initializing a Class Instance with Data
3.7 Releasing an Instance's Resources
3.8 Using Namespaces
3.9 Splitting a Class Across Multiple Files
3.10 Creating a Form Based on Another Form
3.11 Passing and Returning Structures and Other Objects
3.12 Creating and Using an Enumeration
3.13 Converting Between Numeric and String Enumeration Values
3.14 Creating a Method That Accepts Different Sets of Arguments
3.15 Using Standard Operators for Nonstandard Purposes
3.16 Enforcing Strong Data Typing in an Otherwise Weakly Typed Collection
4. Forms, Controls, and Other Useful Objects
4.1 Creating and Adding Controls at Runtime
4.2 Iterating Through All Controls on a Form
4.3 Sharing Event-Handler Logic Among Many Controls
4.4 Working with Timers
4.5 Determining if a Control Can Take the Focus
4.6 Programmatically Clicking a Button
4.7 Drawing a Control
4.8 Making a Form the Top-Most Form
4.9 Indicating the Accept and Cancel Buttons on a Form
4.10 Remembering a Form's Position Between Uses
4.11 Attaching a Control to the Edge of a Form
4.12 Moving or Resizing Controls as a Form Resizes
4.13 Limiting the Sizing of a Form
4.14 Centering a Form
4.15 Creating and Moving a Borderless Form
4.16 Creating a Fading Form
4.17 Creating a Nonrectangular Form
4.18 Changing Menus at Runtime
4.19 Creating Shortcut Menus
5. Strings
5.1 Using a StringBuilder
5.2 Creating a String of N Identical Characters
5.3 Creating a String by Repeating a String N Times
5.4 Obfuscating a String
5.5 Converting Binary Data to a Hexadecimal String
5.6 Extracting Substrings from Larger Strings
5.7 Converting a String's Case
5.8 Comparing Strings with Case Sensitivity
5.9 Comparing Strings Without Case Sensitivity
5.10 Converting Strings to and from Character Arrays
5.11 Converting Strings to and from Byte Arrays
5.12 Tallying Characters
5.13 Counting Words
5.14 Removing Extra Whitespace
5.15 Using the Correct End-of-Line Characters
5.16 Replacing Substrings
5.17 Inserting a Character or String
5.18 Inserting a Line
5.19 Double-Spacing a String
5.20 Formatting Numbers into Strings
5.21 Trimming Sets of Characters from a String
5.22 Identifying and Validating Types of Data in a String
5.23 Converting Strings Between Encoding Systems
5.24 Determining a Character's Type
5.25 Parsing Strings
5.26 Concatenating Strings
5.27 Speeding Up String Manipulation
5.28 Counting Occurrences of a Substring
5.29 Padding a String for Exact Length and Alignment
5.30 Converting Tabs to Spaces
5.31 Reversing a String
5.32 Shuffling a String
5.33 Using a Simple String Encryption
5.34 Converting a String to Morse Code
5.35 Adding Strings to an Application's Resources
5.36 Converting Any Data to a String
5.37 Using Regular Expressions to Extract All Numbers
5.38 Getting a Count of Regular Expression Matches
5.39 Getting the Nth Regular Expression Match
5.40 Compiling Regular Expressions for Speed
5.41 Using Regular Expressions to Validate Data
5.42 Using Regular Expressions to Count Characters, Words, or Lines
5.43 Converting a String to and from Base64
5.44 Splitting a String
5.45 Creating a String of Space Characters
6. Numbers and Math
6.1 Using Compact Operator Notation
6.2 Choosing Integers of the Right Size and Type for the Job
6.3 Using Unsigned Integers
6.4 Swapping Two Integers Without Using a Third
6.5 Using Single- and Double-Precision Variables
6.6 Using Decimal Variables for Maximum Precision
6.7 Converting Between Number Types
6.8 Rounding Numbers Accurately
6.9 Declaring Loop Counters Within Loops
6.10 Converting Between Radians and Degrees
6.11 Limiting Angles to a Range
6.12 Creating Double-Precision Point Variables
6.13 Converting Between Rectangular and Polar Coordinates
6.14 Creating Three-Dimensional Variables
6.15 Converting Between Rectangular, Spherical, and Cylindrical Coordinates
6.16 Working with Complex Numbers
6.17 Solving Right Triangles
6.18 Solving Any Triangle
6.19 Determining if a String Contains a Valid Number
6.20 Converting Numbers to Integers
6.21 Calculating p to Thousands of Digits
6.22 Getting a Number's Prime Factors
6.23 Using Recursion to Calculate Factorials
6.24 Manipulating Bits with Bitwise Operators
6.25 Storing and Retrieving Bits in a BitArray
6.26 Enhancing the Random Number Generator
6.27 Generating Random Integers in a Range
6.28 Generating Random Real Numbers in a Range
6.29 Generating Normal-Distribution Random Numbers
6.30 Generating Exponential-Distribution Random Numbers
6.31 Creating a Matrix
6.32 Inverting a Matrix
6.33 Calculating the Determinant of a Matrix
6.34 Solving Simultaneous Equations
6.35 Listing of the MatrixHelper Class
7. Dates and Times
7.1 Getting the System Date and Time
7.2 Accessing the System's Time Zone
7.3 Using System Ticks
7.4 Timing Application Activities
7.5 Calculating Elapsed Time Using Ticks
7.6 Calculating Elapsed Time with the Stopwatch
7.7 Extracting Year, Month, and Day Numbers from a Date Value
7.8 Extracting Hour, Minute, and Second Numbers from a Date Value
7.9 Creating a Date or Time Value from Its Parts
7.10 Formatting Dates and Times
7.11 Parsing and Validating Dates and Times
7.12 Adding to Dates and Times
7.13 Subtracting from Dates and Times
7.14 Determining the Number of Days Between Two Dates
7.15 Determining the Day of the Week for a Date
7.16 Determining the Day of the Year for a Date
7.17 Determining the Number of Days in a Month
7.18 Using Controls to Enter or Select a Date
7.19 Calculating the Phase of the Moon
7.20 Creating a Calendar
7.21 Checking for Leap Years
7.22 Dates and Times in ISO 8601 Formats
8. Arrays and Collections
8.1 Filling an Array While Declaring It
8.2 Sorting Array Elements
8.3 Reversing an Array
8.4 Inserting into an Array
8.5 Shuffling an Array
8.6 Swapping Two Array Values
8.7 Resizing Arrays Without Losing Existing Values
8.8 Quickly Copying Part of an Array into Another
8.9 Writing a Comma-Separated-Values File from a String Array
8.10 Reading a Comma-Separated-Values File into a String Array
8.11 Using a Multivalue Array Instead of a Two-Dimensional Array
8.12 Converting Between Delimited Strings and Arrays
8.13 Formatting an Array as a Single String
8.14 Iterating Through Array Elements
8.15 Passing Arrays to Methods
8.16 Returning Arrays from Functions
8.17 Creating a Collection
8.18 Inserting an Item into a Collection
8.19 Deleting a Collection Item
8.20 Iterating Through a Collection
9. Graphics
9.1 Creating Graphics Objects
9.2 Drawing on Controls for Special Effects
9.3 Letting the User Select a Color
9.4 Working with Coordinate Systems (Pixels, Inches, Centimeters)
9.5 Creating a Bitmap
9.6 Setting a Background Color
9.7 Drawing Lines, Ellipses, and Rectangles
9.8 Drawing Lines One Pixel Wide Regardless of Scaling
9.9 Forcing a Form or Control to Redraw
9.10 Using Transparency
9.11 Scaling with Transforms
9.12 Using an Outline Path
9.13 Using Gradients for Smooth Color Changes
9.14 Drawing Bezier Splines
9.15 Drawing Cardinal Splines
9.16 Limiting Display Updates to Specific Regions
9.17 Drawing Text
9.18 Rotating Text to Any Angle
9.19 Mirroring Text on the Canvas
9.20 Getting the Height and Width of a Graphic String
9.21 Drawing Text with Outlines and Drop Shadows
9.22 Calculating a Nice Axis
9.23 Drawing a Simple Chart
9.24 Creating Odd-Shaped Forms and Controls
9.25 Using the RGB, HSB (HSV), and HSL Color Schemes
9.26 Creating a Rubber-Band Rectangular Selection
9.27 Animating with Transparency
9.28 Substitutions for Obsolete Visual Basic 6.0 Features
10. Multimedia
10.1 Playing an Audio File
10.2 Displaying Image Files
10.3 Playing a Video File
10.4 Making Your Computer Beep
10.5 Creating an Animation Using Multiple Images
10.6 Creating an Animation by Generating Multiple Bitmaps
10.7 Creating an Animation by Drawing at Runtime
10.8 Creating Animated Sprites
10.9 Resizing and Compressing JPEG Files
10.10 Getting JPEG Extended Information
10.11 Creating Thumbnails
10.12 Displaying Images While Controlling Stretching and Sizing
10.13 Scrolling Images
10.14 Merging Two or More Images
10.15 Using Resource Images
10.16 Capturing an Image of the Screen
10.17 Getting Display Dimensions
10.18 Speeding Up Image Processing
10.19 Converting an Image to Grayscale
10.20 Performing Edge Detection on an Image
10.21 Full Listing of the LockImage Class
11. Printing
11.1 Enumerating Printers
11.2 Sending "Raw" Data to a Printer
11.3 Get Details About the Default Printer
11.4 Creating a Print Preview
11.5 Prompting for Printed Page Settings
11.6 Drawing Text and Graphics to a Printer
11.7 Determining the Print Destination
11.8 Creating Graph Paper
12. Files and File Systems
12.1 Enumerating Drives
12.2 Determining if a Directory Exists
12.3 Creating a New Directory
12.4 Copying Directories
12.5 Moving Directories
12.6 Renaming Directories
12.7 Parsing File and Directory Paths
12.8 Searching Iteratively Through Directories and Subdirectories
12.9 Finding Directories and Files Using Wildcards
12.10 Determining if a File Exists
12.11 Getting and Setting File Attributes
12.12 Accessing Special User and Windows Directories
12.13 Determining the Space on a Drive
12.14 Browsing for a Directory
12.15 Getting File Information
12.16 Using File-Access Methods
12.17 Reading and Writing Files as Strings
12.18 Reading and Writing Binary Files
12.19 Copying or Moving a File
12.20 Sending a File to the Recycle Bin
12.21 Creating a Temporary File
12.22 Calculating a Checksum for a File
12.23 Comparing Two Files for Equality
12.24 Locking a File During Access
12.25 Reading from a File at a Specific Position
12.26 Reading and Writing Objects in a File
12.27 Creating a Comma-Separated-Values File
13. Databases
13.1 Connecting to a Data Provider
13.2 Issuing SQL Commands
13.3 Retrieving Results from a Database Query
13.4 Using SQL Parameters
13.5 Using Stored Procedures
13.6 Using Transactions
13.7 Storing the Results of a Query in Memory
13.8 Creating In-Memory Data Tables Manually
13.9 Writing In-Memory Data Tables to an XML File
13.10 Reading an XML File into In-Memory Data Tables
14. Special Programming Techniques
14.1 Preventing Multiple Instances of a Running Application
14.2 Creating a Simple User Control
14.3 Describing User Control Properties
14.4 Starting Other Applications by EXE, Document, or URL
14.5 Waiting for Applications to Finish
14.6 List All Running Processes
14.7 Terminating a Running Process
14.8 Pausing Execution of a Program
14.9 Control Applications by Simulating Keystrokes
14.10 Watching for File and Directory Changes
14.11 Creating an Icon in the System Tray
14.12 Accessing the Clipboard
14.13 Adding Tooltips to Controls
14.14 Dragging and Dropping Files to a ListBox
14.15 Dragging and Dropping Between ListBox Controls
14.16 Disposing of Objects Appropriately
14.17 Fine-Tuning Garbage Collection
14.18 Moving the (Mouse) Cursor
14.19 Intercepting All Key Presses on a Form
14.20 Accessing the Registry
14.21 Running Procedures in Threads
14.22 Reading XML into a TreeView
14.23 Creating an XML Document
14.24 Validating an XML Document
14.25 Using Generic Collections
14.26 Creating a Screensaver
14.27 Localizing the Controls on a Form
14.28 Adding Pop-up Help to Controls
14.29 Maintaining User-Specific Settings Between Uses of an Application
14.30 Verifying a Credit Card Number
14.31 Capturing a Console Application's Output
14.32 Reading an Assembly's Details
14.33 Performing Serial I/O
14.34 Rebooting the System
15. Exceptions
15.1 Catching an Exception
15.2 Throwing an Exception
15.3 Catching Unhandled Exceptions
15.4 Displaying Exception Information
15.5 Creating New Exception Types
15.6 Ignoring Exceptions in a Block of Code
16. Cryptography and Compression
16.1 Generating a Hash
16.2 Encrypting and Decrypting a String
16.3 Encrypting and Decrypting a File
16.4 Prompting for a Username and Password
16.5 Handling Passwords Securely
16.6 Compressing and Decompressing a String
16.7 Compressing and Decompressing a File
16.8 Generating Cryptographically Secure Random Numbers
16.9 Complete Listing of the Crypto.vb Module
16.10 Complete Listing of the Compress.vb Module
17. Web Development
17.1 Displaying Web Pages on a Form
17.2 Accessing Content Within an HTML Document
17.3 Getting All Links from a Web Page
17.4 Get the Local Computer's IP Address
17.5 Resolving a Host Name or IP Address for Another Computer
17.6 Pinging an IP Address
17.7 Using FTP to Download Files
17.8 Calling a Web Service
17.9 Sending Email Using SMTP
17.10 Getting POP3 Emails
17.11 Sending a Message to Another Computer
17.12 Adding Hyperlinks to a (Desktop) Form
Index
商品描述(中文翻譯)
**描述**
本書將幫助您解決超過 300 個 Visual Basic 2005 程式設計師每天面對的最常見和不太常見的任務。如果您是一位經驗豐富的 .NET 開發人員、初學者 Visual Basic 程式設計師,或是一位尋求從 VB6 簡單明瞭遷移到 Visual Basic 2005 的開發人員,《Visual Basic 2005 食譜》提供了一系列實用的問題解決方案,涵蓋廣泛的 Visual Basic 程式設計任務。
《Visual Basic 2005 食譜》中的簡明解決方案和範例從簡單任務到更複雜的任務,根據您需要解決的問題類型進行組織。幾乎每個食譜都包含完整的、經過文檔記錄的程式碼範例,展示如何解決特定問題,並討論底層技術的運作方式,概述替代方案、限制和其他考量。與所有 O'Reilly 食譜一樣,每個食譜都幫助您快速理解問題,學習如何解決它,並預見潛在的權衡或後果。
本書的有用特點包括:
- 超過 300 個以 O'Reilly 熟悉的問題-解決-討論格式撰寫的食譜
- 數百個可供下載的程式碼片段、範例和完整解決方案
- 提供 VB6 更新,提醒 VB6 程式設計師 Visual Basic 2005 中的破壞性變更
- 針對 Visual Basic 2005 特性而非先前版本的食譜
- 涵蓋日常數據操作技術和語言基礎的程式碼範例
- 專注於使用線性代數方法進行多媒體和數學轉換的高級專案
- 涵蓋檔案和檔案系統、列印和資料庫的專門主題
此外,您還會發現有關密碼學和壓縮、圖形以及特殊程式設計技術的章節。無論您是初學者還是專家,《Visual Basic 2005 食譜》都能幫助您節省時間,隨時提供您所需的程式碼。
**目錄**
**前言**
**1. Visual Basic 程式設計**
1.1 創建 Windows Forms 應用程式
1.2 創建控制台應用程式
1.3 創建 ASP.NET Web Forms 應用程式
**2. 開發環境**
2.1 發現和使用程式碼片段
2.2 創建新的片段
2.3 共享片段
2.4 將片段檔案添加到 Visual Studio
2.5 獲取應用程式的版本號
2.6 讓 Visual Studio 自動更新應用程式的版本號
2.7 設定應用程式的啟動表單
2.8 設定啟動為 Sub Main 程序
2.9 獲取應用程式的命令列
2.10 測試應用程式的命令列
2.11 混淆應用程式
2.12 確定應用程式是否在 Visual Studio 環境中運行
2.13 訪問環境變數
2.14 訪問登錄檔
2.15 獲取系統資訊
2.16 獲取使用者名稱
**3. 應用程式組織**
3.1 創建程式碼模組
3.2 創建類別
3.3 創建結構
3.4 創建其他項目類型
3.5 創建物件實例
3.6 使用數據初始化類別實例
3.7 釋放實例的資源
3.8 使用命名空間
3.9 將類別拆分到多個檔案中
3.10 基於另一個表單創建表單
3.11 傳遞和返回結構及其他物件
3.12 創建和使用列舉
3.13 在數值和字串列舉值之間轉換
3.14 創建接受不同參數集的方法
3.15 對非標準目的使用標準運算符
3.16 在其他弱類型集合中強制強類型
**4. 表單、控制項和其他有用物件**
4.1 在執行時創建和添加控制項
4.2 遍歷表單上的所有控制項
4.3 在多個控制項之間共享事件處理邏輯
4.4 使用計時器
4.5 確定控制項是否可以獲得焦點
4.6 程式碼點擊按鈕
4.7 繪製控制項
4.8 使表單成為最上層的表單
4.9 在表單上指示接受和取消按鈕
4.10 記住表單在使用之間的位置
4.11 將控制項附加到表單的邊緣
4.12 隨著表單大小調整控制項的大小或位置
4.13 限制表單的大小
4.14 將表單置中
4.15 創建和移動無邊框的表單
4.16 創建漸變表單
4.17 創建非矩形表單
4.18 在執行時更改菜單
4.19 創建快捷菜單
**5. 字串**
5.1 使用 StringBuilder
5.2 創建 N 個相同字符的字串
5.3 通過重複字串 N 次創建字串
5.4 混淆字串
5.5 將二進位資料轉換為十六進位字串
5.6 從較大的字串中提取子字串
5.7 轉換字串的大小寫
5.8 進行大小寫敏感的字串比較
5.9 進行不區分大小寫的字串比較
5.10 將字串轉換為和從字符陣列轉換
5.11 將字串轉換為和從位元組陣列轉換
5.12 計算字符數
5.13 計算單詞數
5.14 移除多餘的空白
5.15 使用正確的行結束字符
5.16 替換子字串
5.17 插入字符或字串
5.18 插入行
5.19 將字串雙倍間隔
5.20 將數字格式化為字串
5.21 從字串中修剪字符集
5.22 識別和驗證字串中的數據類型
5.23 在編碼系統之間轉換字串
5.24 確定字符的類型
5.25 解析字串
5.26 串接字串
5.27 加速字串操作
5.28 計算子字串的出現次數
5.29 將字串填充到精確的長度和對齊
5.30 將制表符轉換為空格
5.31 反轉字串
5.32 隨機排列字串
5.33 使用簡單的字串加密
5.34 將字串轉換為摩斯密碼
5.35 將字串添加到應用程式的資源中
5.36 將任何數據轉換為字串
5.37 使用正則表達式提取所有數字
5.38 獲取正則表達式匹配的計數
5.39 獲取第 N 次正則表達式匹配
5.40 編譯正則表達式以提高速度
5.41 使用正則表達式驗證數據
5.42 使用正則表達式計算字符、單詞或行數
5.43 在 Base64 之間轉換字串
5.44 拆分字串
5.45 創建空格字符的字串
**6. 數字與數學**
6.1 使用緊湊運算符表示法
6.2 為工作選擇合適大小和類型的整數
6.3 使用無符號整數
6.4 在不使用第三個整數的情況下交換兩個整數
6.5 使用單精度和雙精度變數
6.6 使用十進制變數以獲得最大精度
6.7 在數字類型之間轉換
6.8 精確地四捨五入數字
6.9 在迴圈內聲明迴圈計數器
6.10 在弧度和度之間轉換
6.11 限制角度在範圍內
6.12 創建雙精度點變數
6.13 在直角坐標和極坐標之間轉換
6.14 創建三維變數
6.15 在直角、球面和圓柱坐標之間轉換
6.16 處理複數
6.17 解決直角三角形
6.18 解決任意三角形
6.19 確定字串是否包含有效數字
6.20 將數字轉換為整數
6.21 計算 π 到千位數
6.22 獲取數字的質因數
6.23 使用遞迴計算階乘
6.24 使用位運算操作位元