Difference between revisions of "Code samples"

From HashVB
Jump to: navigation, search
m (Reverted edit of ErdroNzele, changed back to last version by Dee)
 
(84 intermediate revisions by 21 users not shown)
Line 1: Line 1:
 +
<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.
  
==Variables==
+
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! :)
* [[Is it an integer|How do you tell if a number is an integer?]]
+
* [[Identifying data types|Obtain the type name for a variable]]
+
* [[Passing UDTs to Classes|Pass a user defined type to a class]]
+
  
 
==COM objects==
 
==COM objects==
 
* [[Events from a module|Firing events in an object from a code module]]
 
* [[Events from a module|Firing events in an object from a code module]]
 
* [[Modularised Subclassing|Modularised Subclassing using interfaces and CopyMemory]]
 
* [[Modularised Subclassing|Modularised Subclassing using interfaces and CopyMemory]]
 +
* [[Modularised Subclassing The Same Object Twice|Modularised Subclassing (the same object twice) using interfaces and CopyMemory]]
 
* [[Singletons|Creating singleton objects]]
 
* [[Singletons|Creating singleton objects]]
 +
* [[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==
 +
* [[Create a shortcut|Creating shortcuts to files]]
 +
* [http://www.earlsoft.co.uk/tips/fileio.php File I/O. Reliably]
 +
* [[Special folders|Getting special folder paths]]
 +
* [[API_Recursive_DIR_Structure|How to iterate through a directory structure using APIs]]
 +
* [[Working with INI files in .NET|Working with INI files in .NET]]
 +
 +
==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]]
 +
* [[Enumerating IPs|Enumerating the IP addresses allocated to the local machine]]
 +
* [[Buffering TCP Data|Buffering TCP data incoming from a socket]]
 +
* [[WebGet|Downloading files from websites using the WinInet API]]
 +
 +
==Strings==
 +
* [[GUIDs|Creating unique IDs (GUIDs)]]
 +
* [[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==
* [[Mouse Hover and Out Events|How to Catch Mouse Hover and Out Events]]
+
* [[Control arrays|Creating and using control arrays]]
 +
* [[Mouse Hover and Out Events|How to catch mouse hover and out events]]
 
* [[Catch KeyPresses over whole form|How to catch KeyPresses on a form when a control has focus]]
 
* [[Catch KeyPresses over whole form|How to catch KeyPresses on a form when a control has focus]]
 +
* [[Edit Menus and the RichTextBox Control|Edit Menus and the RichTextBox Control]]
 +
* [[ComDlg|Common Dialog API Wrapper Class]]
 +
* [[DynamicControl|Dynamic control creation]]
 +
* [[Streaming HTML content into a webbrowser control from VB|Streaming HTML into a webbrowser control from VB]]
  
===GDI===
+
===Graphics===
 
* [[Drawing with GDI|Introduction to GDI drawing]]
 
* [[Drawing with GDI|Introduction to GDI drawing]]
 +
* [[Using GDI to draw to a backbuffer|Drawing with a backbuffer]]
 
* [[Drawing an image to a DC|How to draw an image to a DC with GDI]]
 
* [[Drawing an image to a DC|How to draw an image to a DC with GDI]]
 +
* [[All About StretchBlt|All about StretchBlt]]
 +
* [[Pattern Brushes|Pattern Brushes]]
 +
* [http://www.visualbasicforum.com/showthread.php?t=129548 BitBlt]
 +
* [[Creating Fonts|Creating Fonts]]
 +
* [[Drawing sprites using any colour as transparent|Drawing sprites using any colour as transparent]]
 +
* [[SaveJPG|Saving JPEGs using GDI+ in Windows XP]]
 +
* [[GetDefaultIcon|Get Default File Icon]]
 +
* [[PersistentGraphics|Persistent Graphics in VB.Net]]
 +
 +
===Look & Feel===
 +
* [[XP style|Using XP style controls in your application]]
 +
* [[Creating Transparent Controls (.NET)|Creating a transparent control in .NET]]
 +
* [[Tabbed dialogs|Using Tab controls in your applications]]
  
 
===Text boxes===
 
===Text boxes===
 
* [[Numberboxes|Allowing numeric values only]]
 
* [[Numberboxes|Allowing numeric values only]]
* [http://www.earlsoft.co.uk/tips/chat.php Srolling chat windows]
+
* [[Chat windows|Scrolling chat windows]]
 +
 
 +
===List boxes===
 +
* [[Listbox Quickfind|Find items in a ListBox speedily]]
  
 
===Windows===
 
===Windows===
 
* [[Always on top|Making a window "Always on top"]]
 
* [[Always on top|Making a window "Always on top"]]
* [http://www.earlsoft.co.uk/tips/drag.php Dragging windows/controls the easy way]
+
* [[Dragging windows|Dragging windows/controls the easy way]]
 
* [[Creating Floating Tool Windows|How to create a tool window that floats above your app]]
 
* [[Creating Floating Tool Windows|How to create a tool window that floats above your app]]
* [[Subclassing|How to subclass a window to catch useful windows messages]]
+
* [[Subclassing|How to subclass a window to catch useful windows messages in VB6]] and in [[Subclassing in .NET|VB.NET]]
 
* [[Modularised Subclassing|Modularised Subclassing using interfaces and CopyMemory]]
 
* [[Modularised Subclassing|Modularised Subclassing using interfaces and CopyMemory]]
 +
* [[Modularised Subclassing The Same Object Twice|Modularised Subclassing (the same object twice) using interfaces and CopyMemory]]
 +
* [http://www.vbwm.com/articles/builder/viewer.asp?ArticleID=16 Regions and windows]
  
==File handling==
+
==Variables==
* [http://www.earlsoft.co.uk/tips/fileio.php File I/O. Reliably]
+
* [http://www.bytemycode.com/snippets/snippet/251 Hashtables in VB6]
* [[Special folders|Getting special folder paths]]
+
* [[Is it an integer|How do you tell if a number is an integer?]]
* [[API_Recursive_DIR_Structure|How to iterate through a directory structure using APIs]]
+
* [[Identifying data types|Obtain the type name for a variable]]
 
+
* [[Passing UDTs to Classes|Pass a user defined type to a class]]
==Networking==
+
* [[Pointers and CopyMemory|Pointers and CopyMemory]]
* [[Detecting_Network_Adapters|How to get a list of the network adapters on the system]]
+
* [http://xtremevbtalk.com/showthread.php?t=78889 Sorting]
 +
* [[Storing collections in property bags]]
  
 
==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_the_Freezing|Sleeping without freezing the program]] (uses DoEvents)
+
* [[Sleep without locking|Sleeping without locking up the program]] (uses DoEvents)
* [[Why_DoEvents_Are_Evil|Why DoEvents Are Evil]]
+
* [[Why_DoEvents_Are_Evil|Why DoEvents can cause problems]]
 
* [[Windows version|Detecting the version of Windows]]
 
* [[Windows version|Detecting the version of Windows]]
 
* [[Close_Without_End|How to close your app without using End]]
 
* [[Close_Without_End|How to close your app without using End]]
 +
* [[API Errors In Plain English|How to translate an API error to its textual equivalent]]
 +
* [[Standards of Nomenclature and Semantics|Standards of nomenclature and semantics]]
 +
* [[SecondsToHMS|Converting seconds to Hours:Minutes:Seconds]]

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

File handling

Networking

Strings

User interface

Graphics

Look & Feel

Text boxes

List boxes

Windows

Variables

Miscellaneous