Hosted by RachaelArnold <www.rachaelarnold.com>
This document lists the embedded name and description of every code snippet included in a basic installation of Visual Basic 2005 Express. The snippets are arranged alphabetially by VBE categorization.
Activates a running application using the name of the application.
Activates a running application using the process ID of the application.
Saves the output from a command console application to a string.
Changes the background and text color of the console window.
Checks for current version using ClickOnce.
Checks whether updates to the application are available for download.
Clears the console window.
Deletes file from isolated storage.
Determines the Amount of Isolated Storage Available.
Determines the scope of the isolated storage.
Downloads files synchronously using ClickOnce.
Returns a list of all the resources in an assembly.
Sets the cursor of a Windows form from a cursor file that is an embedded resource of the application.
Loads an assembly at run time.
Makes an asynchronous method call using the BackgroundWorker component.
Writes a prompt and then reads in the user request. It is run from a console application.
Iterates through the command line arguments.
Reads the text from a file in isolated storage.
Assigns an image resource in the My Application designer to the PictureBox1's Image property.
Retrieves the text from a file that is an embedded resource of an assembly.
Writes a string to the assembly or user-isolated storage.
Sends keystrokes to an application.
Closes all the running instances of Notepad.
Updates ClickOnce application asynchronously.
Update a ClickOnce application Synchronous.
Writes a message to the application log.
Writes a message to the application event log.
Converts an ArrayList to a strongly typed array using ToArray(Type)
Creates a collection to hold a specific type of items.
Creates a dictionary to hold specific types of items indexed by key.
Creates a sorted dictionary to hold a specific type of items.
Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Indexes into strongly typed dictionary by using a key.
Initializes a one-dimensional array.
Iterates through specific item types in a collection.
Iterates through all the items in a dictionary.
Iterates through all the items in a dictionary based on the sorted list of keys.
Finds the index of a given element in an array.
Declares an array of String objects, populates it, and then sorts it alphabetically.
Uses the #If compiler directive to control which block of code is compiled into the assembly.
Loops until a condition is True.
Loops while a condition is True.
Loops until a condition is True.
Loops while a condition is True.
Loops through a collection of items.
Loops through a sequence of numbers.
Inserts an If...Else...End If statement.
Inserts an If...ElseIf...Else...End If statement.
Inserts an If..End If statement.
Inserts a Select Case statement.
Inserts a While...End While statement.
Provides a basic implementation for a new exception class.
Throws an Exception.
Inserts a Try...Catch...End Try statement.
Inserts a Try...Catch...Finally...End Try statement.
Inserts a Try...Finally...End Try statement.
Inserts a Using statement.
Defines the addition (+) operator on a class.
Defines a function to call a Windows API.
Defines the comparison operators (> and <).
Defines the CType Operators on a class.
Declares an event.
Defines a default property or index property.
Uses the Sub keyword to define a private method that does not return a value.
Defines a Property with a backing field.
Uses the Sub keyword to define a method that does not return a value.
Defines the equality Operators (= and <>).
Defines a Function that uses Generic parameters.
Defines a Function that takes a variable number of parameters.
Defines an Overridable Sub.
Uses the Function keyword to define a procedure that returns a value.
Uses the Sub keyword to define a procedure that does not return a value.
Defines a ReadOnly Property with a backing field.
Overrides the Dispose Function according to the Dispose Finalize pattern.
Defines a Sub with an argument whose value can be changed by the code in the method.
Defines a WriteOnly Property with a backing field.
Defines an enumeration.
Defines an enumeration with specified integer values.
Defines a Generic Type.
Defines an interface.
Defines a structure.
Gets the string name of an enumeration value.
Implements the Dispose Finalize pattern.
Converts a relative Uri to an absolute Uri
Determines whether the network connection is available on the local computer.
Downloads a file using http.
Shows how to enumerate serial ports using the My object.
Determines whether the specified Web site responds.
Reads Data from a Serial Port
Uses the MailMessage class to send an e-mail message.
Uploads a local file to the Internet.
Uses a SerialPort to dial a phone number.
Adds a new row to a typed DataTable
Calls ExecuteNonQuery on an existing command. Wraps the execution in a try/finally block to return the connection object to it's previous state
Fetches data from a database using the SqlCommand.ExecuteReader method of an existing data command.
Executes a SQL statement that returns a single value using the SqlCommand.ExecuteScalar method of an existing data command.
Gets the current row within a binding source and converts it to the specific row. Recomended method for capturing the current, rather then using BindingSource.Position which may return a different row based on the sorting of the DataView
Creates a data relation between two data tables in a dataset.
Creates a DataColumn object and sets the DataColumn.Expression property to calculate the order total.
Calls the ExecuteReader method of a data command to execute a Select statement.
Constructs a command object for executing a stored procedure with parameters
Creates a SQL Connection providing replacements for the typical connection name/value pairs for a SQL Express Connection using User Instance=True
Creates a SQL Connection providing replacements for the typical connection name/value pairs
Extends a TableAdapter using partial classes. Includes the namespace required to reference existing TableAdapters
Implements a Try/Catch block that handles Exception, DataException, and all the exceptions that derive from DataException.
Loads the data from one table in an Access database into a DataSet object.
TableAdapter methods that "Retun No Value" use ExecuteNonQuery which returns the rows affected. This Snippet returns the value from one of the command parameters on a TableAdapter.
Convert an Array of Bytes into a String
Returns the hexadecimal representation of an integer.
Returns the octal string representation of an integer.
Converts a string to a byte array.
Converts between Hiragana and Katakana characters in a String.
Converts between Simplified Chinese and Traditional Chinese characters in a String.
Converts between Wide and Narrow characters in Strings.
Calculates the difference in days between two dates and also constructs a TimeSpan value for that difference.
Calculates the difference in seconds between two times in the same day, and also constructs a TimeSpan value for that difference.
Constructs a string literal that is three lines long.
Returns the user name and provider name from an e-mail address.
Removes all occurrences of one string from another string.
Compares two files.
Copies a directory and all its files and subdirectories.
Copies the file Source.txt to a second file, Copy.txt.
Creates a new file.
Creates two new folders on a computer.
Creates a name for a temporary file.
Deletes a file after confirming deletion with the user.
Sets a Boolean variable indicating whether a specified file exists.
Sets a Boolean variable indicating whether a specified folder exists.
Obtains the size of a file and assigns it to a variable
Enumerates the drives on a computer.
Obtains the amount of disk space available.
Obtains an object containing information about a file.
Moves a file to a new directory.
Returns the values in each column and row from a text file with comma-delimited data. Other delimiters may be used.
Reads data from a binary file.
Reads the contents of a text file in the My Documents folder into a single string.
Reads the contents of a text file into a string.
Renames a directory.
Renames a file.
Retrieves the drive names on the local computer.
Searches a directory for files recursively.
Searches files in a directory for an expression.
Writes a line of text to a text file, replacing any text if the file exists.
Writes bytes to a binary file.
Calculates the monthly payment on a loan.
Converts an angle from degrees to radians and then calculates cosine of the angle
Returns a Double specifying the sum-of-years digits depreciation of an asset for a specified period.
Converts an angle from degrees to radians and then calculates sine of the angle
Converts an angle from degrees to radians and then calculates the tangent of the angle
Generates a random integer between an upper bound and a lower bound.
Copies an instance of a serializable class to the Clipboard.
Copies an Image to the Clipboard.
Copies a String to the Clipboard.
Gets an Image from the Clipboard and stores it in an Image object.
Gets a String from the Clipboard and stores it in a String object
Adds a ToolTip to a Windows Forms Control.
Resizes a button by measuring its text and then resetting its Width.
Uses AutoSize to dynamically resize a button to the length of its text.
Selects a range of dates in a MonthCalendar control.
Uses an ArrayList object as the data source for a ComboBox control.
Fills a ComboBox with data from a DataTable object.
Provides automatic text completion for a combobox.
Locks the column widths of a DataGridView.
Clears items from a bound ListBox control.
Fills a ListBox with data from a DataTable object.
Locates the first incidence of a string in a ListBox control.
Selects an item in a ListBox control, programmatically.
Determines the selected item in a ListView and assigns it to a variable.
Adds a check mark to a ToolStripMenuItem.
Adds a context menu to a windows form.
Add a shortcut to a ToolStripMenuItem.
Adds menu items to an existing menu
Deletes a ToolStripMenuItem from an existing MenuStrip.
Increments a ProgressBar by a fixed amount, upon each iteration.
Creates a Group of RadioButtons from an Array of Strings.
Adds the text "This text is in bold." to an existing RichTextBox control.
Loads a file in RTF format into a RichTextBox control.
Positions the cursor in a RichTextBox.
Saves the content of the RichText box to a RTF file.
Enters a multiline string into a multiline textbox.
Determines the selected node in a TreeView control and assigns it to a variable.
Creates and fills a Bitmap object and displays it in an existing Windows Forms PictureBox control.
Creates a TextureBrush object with an image file.
Creates a Pen object.
Creates a SolidBrush object.
Draws a triangle by connecting a series of points.
Displays an animated GIF.
Draws a filled ellipse on a form.
Draws a filled rectangle on a form.
Draws a line on a form.
Draws a pie chart.
Draws a rubber band rectangle on the form.
Draws a shape with gradient fill.
Draws outlined ellipses on a form.
Draws outlined rectangle on a form.
Draws text on a form.
Draws text on a form in a vertical orientation.
Creates a font by using three overloads of the Font constructor.
Creates a new instance of a Windows forms TextBox control at run time.
Arranges the child forms in a cascading layout.
Converts mouse coordinates from a mouse event into screen coordinates.
Creates and displays a new MDI child form.
Sets the opacity of a form to make it transparent.
Retrieves the active MDI child form and the active control on the child form.
Finds the selected control on a form.
Monitors for modifier keys such as the SHIFT, ALT, and CTRL keys.
Displays a windows form.
Eliminates the TitleBar from a Form
Shows how the TopMost property controls whether a form is a top-most form. A top-most form will float above other, non–top-most forms even when it is not active.
Moves a form by dragging any part of it with the mouse. This feature is particularly useful when the form has no title bar.
Plays a beep.
Resizes a form.
Overrides the default ProcessCmdKey function of a Windows Forms Control and restricts user input to numeric and navigation keys.
Retrieves information from the parent MDI form.
Determines how a dialog box was closed.
Sets the location, in pixels, of the the top-left corner of the form.
Plays a looping sound in the background.
Plays a sound from a file.
Stops a sound playing in the background.
Adds a new element to an XML document instance.
Enumerates the attributes of an XmlNode.
Locates an element in an XML file by Element name.
Infers a Schema from an existing XML file and saves it as a seperate schema file.
Iterates the elements in an XML document by element name.
Iterates through the nodes of an XML document using the XPathNavigator.
Reads class data that was previously written to an XML file using the XmlSerializer class.
Uses the XMLTextReader class to extract the contents from an XML file.
Reads XML data from a string.
Read XML data from a location defined as an URL.
Creates an iterator to walkthrough selected nodes.
Transforms XML into HTML using a XSL stylesheet.
Transforms XML into HTML using XSLT.
Writes the data from a class to an XML file using the XmlSerializer class.