Visual Basic 2008 Recipes (eBook)

A Problem-Solution Approach
eBook Download: PDF
2008 | 1st ed.
XXII, 704 Seiten
Apress (Verlag)
978-1-4302-0604-0 (ISBN)

Lese- und Medienproben

Visual Basic 2008 Recipes -  Todd Herman,  Allen Jones,  Matthew MacDonald,  Rakesh Rajan
Systemvoraussetzungen
48,14 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

Visual Basic 2008 Recipes is a book of ready-made coding solutions for programmers who don't want spend a lot of time reading. Each chapter addresses a specific problem-domain such as multimedia, database access, XML manipulation, etc. Each chapter then presents a number of common problems, with a solution following each problem. Readers appreciate the recipe format, because they can look up a problem, read one to three pages, implement the solution, and then get on with their work. Recipe books are ideal for those who want to spend their days doing, not reading.



Rakesh Rajan was a Microsoft 'Most Valuable Professional' in C# and an MCSD in .NET from the Bangalore, India area. He worked as a software engineer in the U.S. at Trivandrum. Rakesh passed away in 2006.
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

Rakesh Rajan was a Microsoft "Most Valuable Professional" in C# and an MCSD in .NET from the Bangalore, India area. He worked as a software engineer in the U.S. at Trivandrum. Rakesh passed away in 2006.

Contents at a Glance 5
Contents 6
About the Author 13
About the Technical Reviewer 14
Acknowledgments 15
Introduction 16
Application Development 17
1-1. Create a Console Application from the Command Line 18
1-2. Create a Windows- Based Application from the Command Line 21
1-3. Create and Use a Code Module from the Command Line 24
1-4. Create and Use a Code Library from the Command Line 26
1-5. Embed a Resource File in an Assembly 27
1-6. Build Projects from the Command Line Using MSBuild.exe 30
1-7. Access Command-Line Arguments 33
1-8. Include Code Selectively at Build Time 35
1-9. Manipulate the Appearance of the Console 39
1-10. Access a Program Element That Has the Same Name As a Keyword 41
1-11. Create and Manage Strong-Named Key Pairs 42
1-12. Give an Assembly a Strong Name 43
1-13. Verify That a Strong-Named Assembly Has Not Been Modified 46
1-14. Delay Sign an Assembly 47
1-15. Sign an Assembly with an Authenticode Digital Signature 48
1-16. Create and Trust a Test Software Publisher Certificate 53
1-17. Manage the Global Assembly Cache 54
1-18. Make Your Assembly More Difficult to Decompile 55
1-19. Use Implicitly Typed Variables 56
1-20. Use Object Initializers 57
1-21. Use Anonymous Types 60
1-22. Create and Use Extension Methods 61
1-23. Create and Use Lambda Expressions 63
Data Manipulation 67
2-1. Manipulate the Contents of a String Efficiently 67
2-2. Encode a String Using Alternate Character Encoding 70
2-3. Convert Basic Value Types to Byte Arrays 72
2-4. Base64 Encode Binary Data 75
2-5. Validate Input Using Regular Expressions 78
2-6. Use Compiled Regular Expressions 81
2-7. Create Dates and Times from Strings 84
2-8. Add, Subtract, and Compare Dates and Times 86
2-9. Convert Dates and Times Across Time Zones 89
2-10. Sort an Array or an ArrayList 93
2-11. Copy a Collection to an Array 95
2-12. Manipulate or Evaluate the Contents of an Array 96
2-13. Use a Strongly Typed Collection 100
2-14. Create a Generic Type 102
2-15. Store a Serializable Object to a File 105
2-16. Read User Input from the Console 108
Application Domains, Reflection, and Metadata 112
3-1. Load an Assembly into the Current Application Domain 113
3-2. Create an Application Domain 115
3-3. Execute an Assembly in a Different Application Domain 117
3-4. Avoid Loading Unnecessary Assemblies into Application Domains 119
3-5. Create a Type That Cannot Cross Application Domain Boundaries 120
3-6. Create a Type That Can Be Passed Across Application Domain Boundaries 121
3-7. Instantiate a Type in a Different Application Domain 124
3-8. Pass Data Between Application Domains 128
3-9. Unload Assemblies and Application Domains 130
3-10. Retrieve Type Information 131
3-11. Test an Object’s Type 134
3-12. Instantiate an Object Using Reflection 136
3-13. Create a Custom Attribute 139
3-14. Inspect the Attributes of a Program Element Using Reflection 142
Threads, Processes, and Synchronization 144
4-1. Execute a Method Using the Thread Pool 145
4-2. Execute a Method Asynchronously 148
4-3. Creating an Asynchronous Method to Update the User Interface 155
4-4. Execute a Method Periodically 160
4-5. Execute a Method at a Specific Time 162
4-6. Execute a Method by Signaling a WaitHandle Object 165
4-7. Execute a Method Using a New Thread 167
4-8. Synchronize the Execution of Multiple Threads Using a Monitor 169
4-9. Synchronize the Execution of Multiple Threads Using an Event 174
4-10. Synchronize the Execution of Multiple Threads Using a Mutex 178
4-11. Synchronize the Execution of Multiple Threads Using a Semaphore 180
4-12. Synchronize Access to a Shared Data Value 182
4-13. Know When a Thread Finishes 184
4-14. Terminate the Execution of a Thread 186
4-15. Create a Thread-Safe Collection Instance 188
4-16. Start a New Process 189
4-17. Terminate a Process 192
4-18. Ensure That Only One Instance of an Application Can Execute Concurrently 194
Files, Directories, and I/O 197
5-1. Retrieve Information About a File, Directory, or Drive 198
5-2. Set File and Directory Attributes 203
5-3. Copy, Move, or Delete a File or a Directory 204
5-4. Calculate the Size of a Directory 208
5-5. Retrieve Version Information for a File 210
5-6. Show a Just-in-Time Directory Tree in the TreeView Control 211
5-7. Read and Write a Text File 214
5-8. Read and Write a Binary File 217
5-9. Parse a Delimited Text File 218
5-10. Read a File Asynchronously 222
5-11. Find Files That Match a Wildcard Expression 225
5-12. Test Two Files for Equality 226
5-13. Manipulate Strings Representing File Names 228
5-14. Determine Whether a Path Is a Directory or a File 229
5-15. Work with Relative Paths 230
5-16. Create a Temporary File 232
5-17. Get the Total Free Space on a Drive 233
5-18. Show the Common File Dialog Boxes 235
5-19. Use an Isolated Store 237
5-20. Monitor the File System for Changes 239
5-21. Access a COM Port 242
5-22. Get a Random File Name 243
5-23. Manipulate the Access Control Lists of a File or Directory 243
Language Integrated Query (LINQ) 247
6-1. Query a Generic Collection 248
6-2. Query a Nongeneric Collection 250
6-3. Control Query Results 251
6-4. Sort Data Using LINQ 253
6-5. Filter Data Using LINQ 254
6-6. Perform General Aggregate Operations 256
6-7. Perform Average and Sum Calculations 257
6-8. Perform Count Operations 259
6-9. Perform Min and Max Calculations 260
6-10. Group Query Results 262
6-11. Query Data from Multiple Collections 264
6-12. Returning Specific Elements of a Collection 267
6-13. Display Collection Data Using Paging 268
6-14. Compare and Combine Collections 270
6-15. Cast a Collection to a Specific Type 273
LINQ to XML and XML Processing 276
7-1. Create an XML Document 277
7-2. Load an XML File into Memory 281
7-3. Insert Elements into an XML Document 282
7-4. Change the Value of an Element or Attribute 284
7-5. Remove or Replace Elements or Attributes 285
7-6. Query an XML Document Using LINQ 287
7-7. Query for Elements in a Specific XML Namespace 289
7-8. Query an XML Document Using XPath 291
7-9. Join and Query Multiple XML Documents 293
7-10. Convert an XML File to a Delimited File ( and Vice Versa) 294
7-11. Validate an XML Document Against a Schema 298
7-12. Use XML Serialization with Custom Objects 303
7-13. Create a Schema for a .NET Class 306
7-14. Generate a Class from a Schema 307
7-15. Perform an XSL Transform 308
Database Access 312
8-1. Connect to a Database 314
8-2. Use Connection Pooling 317
8-3. Create a Database Connection String Programmatically 319
8-4. Store a Database Connection String Securely 321
8-5. Execute a SQL Command or Stored Procedure 324
8-6. Use Parameters in a SQL Command or Stored Procedure 329
8-7. Process the Results of a SQL Query Using a Data Reader 333
8-8. Obtain an XML Document from a SQL Server Query 336
8-9. Perform Asynchronous Database Operations Against SQL Server 340
8-10. Write Database-Independent Code 343
8-11. Create a Database Object Model 347
8-12. Generate Data Object Classes from the Command Line 351
8-13. Discover All Instances of SQL Server on Your Network 353
Windows Forms 355
9-1. Add a Control Programmatically 356
9-2. Link Data to a Control 359
9-3. Process All the Controls on a Form 360
9-4. Track the Visible Forms in an Application 362
9-5. Find All MDI Child Forms 364
9-6. Save Configuration Settings for a Form 367
9-7. Force a List Box to Scroll to the Most Recently Added Item 370
9-8. Restrict a Text Box to Accepting Only Specific Input 371
9-9. Use an Autocomplete Combo Box 374
9-10. Sort a List View by Any Column 376
9-11. Lay Out Controls Automatically 380
9-12. Make a Multilingual Form 381
9-13. Create a Form That Cannot Be Moved 384
9-14. Make a Borderless Form Movable 385
9-15. Create an Animated System Tray Icon 388
9-16. Validate an Input Control 389
9-17. Use a Drag-and-Drop Operation 391
9-18. Use Context-Sensitive Help 393
9-19. Display a Web Page in a Windows-Based Application 394
9-20. Create a Windows Presentation Foundation Application 397
9-21. Run a Windows Vista Application with Elevated Rights 399
Multimedia 402
10-1. Find All Installed Fonts 403
10-2. Perform Hit Testing with Shapes 405
10-3. Create an Irregularly Shaped Control 408
10-4. Create a Movable Sprite 410
10-5. Create a Scrollable Image 414
10-6. Perform a Screen Capture 416
10-7. Use Double Buffering to Increase Redraw Speed 418
10-8. Show a Thumbnail for an Image 420
10-9. Play a Simple Beep or System Sound 421
10-10. Play a WAV File 423
10-11. Play a Sound File 424
10-12. Show a Video with DirectShow 426
10-13. Retrieve Information About Installed Printers 429
10-14. Print a Simple Document 431
10-15. Print a Multipage Document 434
10-16. Print Wrapped Text 437
10-17. Show a Dynamic Print Preview 439
10-18. Manage Print Jobs 442
Networking and Remoting 447
11-1. Obtain Information About the Local Network Interface 448
11-2. Detect Changes in Network Connectivity 451
11-3. Download Data over HTTP or FTP 453
11-4. Download a File and Process It Using a Stream 456
11-5. Respond to HTTP Requests from Your Application 458
11- 6. Get an HTML Page from a Site That Requires Authentication 462
11-7. Send E-mail Using SMTP 465
11-8. Resolve a Host Name to an IP Address 468
11-9. Ping an IP Address 470
11-10. Communicate Using TCP 472
11-11. Create a Multithreaded TCP Server That Supports Asynchronous Communications 476
11-12. Communicate Using UDP 484
11-13. Communicate Using Named Pipes 487
11-14. Make an Object Remotable 491
11-15. Register All the Remotable Classes in an Assembly 496
11-16. Host a Remote Object in IIS 498
11-17. Control the Lifetime of a Remote Object 499
11-18. Control Versioning for Remote Objects 501
11-19. Consume an RSS Feed 503
Security and Cryptography 505
12-1. Allow Partially Trusted Code to Use Your Strong-Named Assembly 506
12-2. Disable Execution Permission Checks 508
12-3. Ensure the Runtime Grants Specific Permissions to Your Assembly 510
12-4. Limit the Permissions Granted to Your Assembly 512
12-5. View the Permissions Required by an Assembly 513
12-6. Determine at Runtime Whether Your Code Has a Specific Permission 515
12-7. Restrict Who Can Extend Your Classes and Override Class Members 516
12-8. Inspect an Assembly’s Evidence 518
12-9. Determine Whether the Current User Is a Member of a Specific Windows Group 521
12-10. Restrict Which Users Can Execute Your Code 524
12-11. Impersonate a Windows User 527
12-12. Create a Cryptographically Random Number 531
12-13. Calculate the Hash Code of a Password 532
12-14. Calculate the Hash Code of a File 536
12-15. Verify a Hash Code 538
12-16. Ensure Data Integrity Using a Keyed Hash Code 540
12-17. Work with Security-Sensitive Strings in Memory 543
12-18. Encrypt and Decrypt Data Using the Data Protection API 546
Code Interoperability 549
13-1. Call a Function in an Unmanaged DLL 550
13-2. Get the Handle for a Control, Window, or File 553
13-3. Call an Unmanaged Function That Uses a Structure 555
13-4. Call an Unmanaged Function That Uses a Callback 558
13-5. Retrieve Unmanaged Error Information 559
13-6. Use a COM Component in a .NET Client 561
13-7. Release a COM Component Quickly 563
13-8. Use Optional Parameters 564
13-9. Use an ActiveX Control in a .NET Client 566
13-10. Expose a .NET Component to COM 568
13-11. Use a Windows Presentation Foundation Control from a Windows Form 569
Commonly Used Interfaces and Patterns 571
14-1. Implement a Serializable Type 571
14-2. Implement a Cloneable Type 577
14-3. Implement a Comparable Type 581
14-4. Implement an Enumerable Type Using a Custom Iterator 585
14-5. Implement a Disposable Class 592
14-6. Implement a Type That Can Be Formatted 596
14-7. Implement a Custom Exception Class 599
14-8. Implement a Custom Event Argument 603
14-9. Implement the Singleton Pattern 605
14-10. Implement the Observer Pattern 607
Windows Integration 614
15-1. Access Runtime Environment Information 614
15-2. Retrieve the Value of an Environment Variable 618
15-3. Write an Event to the Windows Event Log 619
15-4. Read and Write to the Windows Registry 621
15-5. Search the Windows Registry 624
15-6. Create a Windows Service 627
15-7. Create a Windows Service Installer 632
15-8. Create a Shortcut on the Desktop or Start Menu 635
Index 639

Erscheint lt. Verlag 28.5.2008
Zusatzinfo XXII, 704 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Informatik Programmiersprachen / -werkzeuge Visual Basic
Mathematik / Informatik Informatik Software Entwicklung
Schlagworte Databases • Development • interfaces • language • LINQ • Multimedia • .NET • Processing • programming • Visual BASIC • WINDOWS • XML
ISBN-10 1-4302-0604-7 / 1430206047
ISBN-13 978-1-4302-0604-0 / 9781430206040
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 6,2 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich