Don't click on me...I can't even spell VB

Computer Science 105, 106, & 205

VB.Net Code Snippets for Visual Basic

When you need code for a specific job, then check out this list. Instead of scrounging around in your notes, I put some major code snippets here for you. In most cases they are copied from our VB classroom projects.

  • General Visual Basic Stuff
  • Data Entry

Assign data from textbox to label
Copy selected item in Listbox to a textbox
How to concatenate strings
Simple math operations (computing sales tax)
How to display items & pricing as currency
  • Using List Boxes/ Multiline Textboxes

Load list box from an arraylist
Add Item to list box
Remove list box item
Add items from a dataset

Load list box with items, pricing, & photo information
Getting the list box items, pricing, & photo information
Adding Items & Prices to a list box in one string

Using a For-Each loop to save list box items

Read filenames from a folder to a multiline textbox or list box
Get the project
Get the code


  • Using Controls

Web Browser control
How to display image in a picture box
  • If , Select Case, & Do Loops

Using YES-NO buttons on message box
Intro to using SELECT CASE
Using IF END IF blocks instead of SELECT CASE
For-Next Loops
For Each Loops & the controls collection
How to clear textboxes & radiobuttons from the controls collection even if the form has a container control.

Using Do Loops
Getting a users PIN number
  • Formatting Strings

How to format numbers
How to format data as currency
  • String Functions

How to use the MID function
How to use the LEFT function
How to use the TRIM functions
How to use vbCrLf
How to use String.Replace
  • Variables

How to use module-level variables
Using Totals & Counts with module-level variables


  • Forms & Functions
  • File I/O
  • Custom Classes
  • Multimedia
  • Custom Controls
  • Inheritance, XML documentation, & Windows Help tool.
  • Inheritance Project (Lesson 9)
    Using custom classes through inheritance Shows Help authoring tool you can buy and how to use XML documentation in your methods so they appear in intellisense & the object browser.
  • Working With Excel & VB
  • Access Databases & ADO
  • Access DB & Wizards (VS2010  Version)
  • SQL Databases & ADO 2.0
  • SQL 2005 & XML

VB.Net Support

Database Resources

Return to Main Menu

Copyright 1999-2011 Ronald P. Kessler, Ph.D.
All rights reserved.

Revised: June 19, 2011