Difference between revisions of "Code samples"
From HashVB
m (Moved the Hashtable link into Variables) |
m (Reverted edit of ErdroNzele, changed back to last version by Dee) |
||
(26 intermediate revisions by 12 users not shown) | |||
Line 1: | Line 1: | ||
<div style="float: right; margin-left: 10px;">__TOC__</div> | <div style="float: right; margin-left: 10px;">__TOC__</div> | ||
Below are a selection of VB code samples. Feel free to use any of them in your own projects. | Below are a selection of VB code samples. Feel free to use any of them in your own projects. | ||
+ | |||
+ | Please also feel free to make your own contributions of articles and/or article modifications. The more articles we get the better this resource will be! :) | ||
==COM objects== | ==COM objects== | ||
Line 8: | Line 10: | ||
* [[Singletons|Creating singleton objects]] | * [[Singletons|Creating singleton objects]] | ||
* [[Using For Next on your own class|How to make your classes support For/Next constructs]] | * [[Using For Next on your own class|How to make your classes support For/Next constructs]] | ||
+ | * [[Streaming HTML content into a webbrowser control from VB|Streaming HTML into a webbrowser control from VB]] | ||
==File handling== | ==File handling== | ||
+ | * [[Create a shortcut|Creating shortcuts to files]] | ||
* [http://www.earlsoft.co.uk/tips/fileio.php File I/O. Reliably] | * [http://www.earlsoft.co.uk/tips/fileio.php File I/O. Reliably] | ||
* [[Special folders|Getting special folder paths]] | * [[Special folders|Getting special folder paths]] | ||
Line 16: | Line 20: | ||
==Networking== | ==Networking== | ||
+ | * [[Sharing_in_VbNET|Sharing Folders and Files in Vb.NET]] | ||
* [[Detecting_Network_Adapters|How to get a list of the network adapters on the system]] | * [[Detecting_Network_Adapters|How to get a list of the network adapters on the system]] | ||
* [[Enumerating IPs|Enumerating the IP addresses allocated to the local machine]] | * [[Enumerating IPs|Enumerating the IP addresses allocated to the local machine]] | ||
Line 24: | Line 29: | ||
* [[GUIDs|Creating unique IDs (GUIDs)]] | * [[GUIDs|Creating unique IDs (GUIDs)]] | ||
* [[Shuffling|How to randomise a list]] | * [[Shuffling|How to randomise a list]] | ||
+ | * [[Quotes|Including quote characters in a string]] | ||
+ | * [[Simplifying building of complex strings in code (eg sql statements)]] | ||
==User interface== | ==User interface== | ||
Line 32: | Line 39: | ||
* [[ComDlg|Common Dialog API Wrapper Class]] | * [[ComDlg|Common Dialog API Wrapper Class]] | ||
* [[DynamicControl|Dynamic control creation]] | * [[DynamicControl|Dynamic control creation]] | ||
+ | * [[Streaming HTML content into a webbrowser control from VB|Streaming HTML into a webbrowser control from VB]] | ||
===Graphics=== | ===Graphics=== | ||
Line 44: | Line 52: | ||
* [[SaveJPG|Saving JPEGs using GDI+ in Windows XP]] | * [[SaveJPG|Saving JPEGs using GDI+ in Windows XP]] | ||
* [[GetDefaultIcon|Get Default File Icon]] | * [[GetDefaultIcon|Get Default File Icon]] | ||
+ | * [[PersistentGraphics|Persistent Graphics in VB.Net]] | ||
===Look & Feel=== | ===Look & Feel=== | ||
Line 76: | Line 85: | ||
==Miscellaneous== | ==Miscellaneous== | ||
+ | * [[MD5 Hashing Using the CryptoAPI|MD5 Hashing Using the Windows Cryptography API]] | ||
+ | * [[System Tray|Adding icons to Explorer's System tray]] | ||
* [[Open a URL|Open a URL in a web browser]] | * [[Open a URL|Open a URL in a web browser]] | ||
* [[Sleep without locking|Sleeping without locking up the program]] (uses DoEvents) | * [[Sleep without locking|Sleeping without locking up the program]] (uses DoEvents) |
Latest revision as of 11:26, 8 October 2009
Below are a selection of VB code samples. Feel free to use any of them in your own projects.
Please also feel free to make your own contributions of articles and/or article modifications. The more articles we get the better this resource will be! :)
COM objects
- Firing events in an object from a code module
- Modularised Subclassing using interfaces and CopyMemory
- Modularised Subclassing (the same object twice) using interfaces and CopyMemory
- Creating singleton objects
- How to make your classes support For/Next constructs
- Streaming HTML into a webbrowser control from VB
File handling
- Creating shortcuts to files
- File I/O. Reliably
- Getting special folder paths
- How to iterate through a directory structure using APIs
- Working with INI files in .NET
Networking
- Sharing Folders and Files in Vb.NET
- How to get a list of the network adapters on the system
- Enumerating the IP addresses allocated to the local machine
- Buffering TCP data incoming from a socket
- Downloading files from websites using the WinInet API
Strings
- Creating unique IDs (GUIDs)
- How to randomise a list
- Including quote characters in a string
- Simplifying building of complex strings in code (eg sql statements)
User interface
- Creating and using control arrays
- How to catch mouse hover and out events
- How to catch KeyPresses on a form when a control has focus
- Edit Menus and the RichTextBox Control
- Common Dialog API Wrapper Class
- Dynamic control creation
- Streaming HTML into a webbrowser control from VB
Graphics
- Introduction to GDI drawing
- Drawing with a backbuffer
- How to draw an image to a DC with GDI
- All about StretchBlt
- Pattern Brushes
- BitBlt
- Creating Fonts
- Drawing sprites using any colour as transparent
- Saving JPEGs using GDI+ in Windows XP
- Get Default File Icon
- Persistent Graphics in VB.Net
Look & Feel
- Using XP style controls in your application
- Creating a transparent control in .NET
- Using Tab controls in your applications
Text boxes
List boxes
Windows
- Making a window "Always on top"
- Dragging windows/controls the easy way
- How to create a tool window that floats above your app
- How to subclass a window to catch useful windows messages in VB6 and in VB.NET
- Modularised Subclassing using interfaces and CopyMemory
- Modularised Subclassing (the same object twice) using interfaces and CopyMemory
- Regions and windows
Variables
- Hashtables in VB6
- How do you tell if a number is an integer?
- Obtain the type name for a variable
- Pass a user defined type to a class
- Pointers and CopyMemory
- Sorting
- Storing collections in property bags
Miscellaneous
- MD5 Hashing Using the Windows Cryptography API
- Adding icons to Explorer's System tray
- Open a URL in a web browser
- Sleeping without locking up the program (uses DoEvents)
- Why DoEvents can cause problems
- Detecting the version of Windows
- How to close your app without using End
- How to translate an API error to its textual equivalent
- Standards of nomenclature and semantics
- Converting seconds to Hours:Minutes:Seconds