Visual Basic Source Code Samples

Visual Basic is a great programming language that can handle just about any problem you through at it. Because of this, people have been using VB over the years to handle just about everything from simple screen saver applications to full blown data entry business programs even to fun video games. With so many others having already mastered many of the skills to create these apps, we would be fools to always try to re-invent everything ourselves. Below is a list of a bunch of VB6 source code samples. You can download these and examine them to get great ideas on how to solve similar problems. Please respect whatever copyright notice they have in them though.

  • Level2

    Barcodes are everywhere. From produce at the super market to tattoo’s on peoples necks. At first glance every barcode looks the same. However, in reality there are many different types of codes that encode data in different ways. Barcode software is able to detect what type of encoding the barcode is using by looking at the layout of the blocks in the code. This in and of itself is a fascinating feat. However, the more fascinating thing is that a seemingly random set of blocks actual can encode some pretty interesting information.

  • Level1
    You can interact with any built in Windows API function from Visual Basic. This source sample shows how we can use the GetSystemMetrics API function in order to find out if Windows was started in safe mode or not.
  • Level1
    Drag and Drop is cool and very useful feature that any modern application must implement. This sample demonstrates how you can allow users to drag files from explorer onto a listbox.
  • Level1
    The Windows Registry is a great place to store program settings. Visual basic has SaveSettings and GetSettings functions to be able to easily store and retrieve data from the registry.
  • Level1
    In this day and age you will find yourself needing to convert colors that are specified in the format for websites into RGB colors that can be used in your VB programs. This is easy to do with this very simple code snippet.
  • Level1
    New VB developers quickly learn how to Unload their forms. This source code snippet shows you how you can add a little style to your form unloading event. Instead of just making it disappear the form will shrink into non-existence.
  • Level1
    Many people have seen the Find and Replace functionality in Word or other applications. You can implement similar functionality in your VB programs with just a few lines of code.
  • Level1
    At times we want to say that so many words can or must be entered in a text box field. Getting the character count of a field is easy in Visual Basic, but getting the word count takes a little more work. This source code shows you how to calculate this word count.
  • Level1
    Visual Basic Arrays are very handy and at times somewhat complicated, especially if you want to remove an item from it or redefine its size. This VB sample shows you how to do this.
  • Level1
    Controls in VB are very handy. However, none of them have built in methods to save their contents out to the hard drive. This source sample shows you exactly how to take all the items in a list and save them into a text file you specify.
  • Level1
    Visual Basic can be used for lower level functionality such as copying all the data from one file into another one. This source code sample shows you how to do this using the Open, Get, Put, and Close File IO Functions.
  • Level1
    This is a simple and fun example of a cool effect you can do in VB - Setting the forms background to a gradiant of color. It also showcases how you can use the VB6 For loop.
  • Level1
    Every Window's system has a bunch of fonts installed on it that we can use to display text in different ways. This sample shows how we can use Visual Basic's Screen object to query these fonts and list them all in a combo box.
  • Level1
    A fun thing to develop when you are first learning how to program is a program launcher. This sample source code shows you how you can use VB's built in shell command in order to launch other programs from within your custom application.
  • Level1
    Visual Basic gives us access to the Screen object in order to find out information about the end users screen resolution and other settings. We can use this in order to make our form appear in the center of the screen. This sample source code shows you how.
  • Level1
    MP3 files are common place now days. When Visual Basic 6.0 first came out MP3 files weren't even used. However, you can still use VB6 to read all the tag information of this song files.
  • Level1
    Writing network related programs is fun and exciting. At times it almost seems like magic. This source code sample shows how you can create a very basic web server that when your browser connects to it the specified text will show up in the browser. This uses the Microsoft Winsock control.

    This source code sample demonstrates how you can create a very, very, basic web server. It is not intended for you to actually use but instead to just wet your appetite with a simple networking example.

  • Level1
    See an example of how you can interact with the system to find out all files in a given folder. Further add all these files (and their paths) to a listbox control.
  • Level1
    Learn in this simple source code snippet exactly how you can delete a file from your computer using Visual Basic. It is a very simple example to showcase the Kill command in VB.
  • Level1
    A simple source snippet that shows how you can tile any image both horizontally and vertically on a VB form.
  • Level2
    This sample source code shows you exactly how to create a PDF file from within your VB application with out having to buy a third party control or dll. It gives an example of creating a PDF and adding text to it.
  • Level2
    This full program is a simple calculator like what comes with windows. It demonstrates many controls and commands.
  • Level2
    See how to write a full working version of the Concentration game.
  • Level2
    Learn how to create a full hangman game with graphics. This program uses forms, timers, graphics, and many other common controls.
  • Level2
    This code shows a full tic tac toe. It uses forms, graphics, a simple AI algorithm, and other fun game stuff.
  • Level2
    This is a simple game that also shows how to do a fun cryptography method. It also teaches you forms, graphics and other basic VB controls.
  • Level3
    This program converts an integer in the range of 1 through 3999 to its equivalent in Roman numerals. It also converts a Roman numeral string to its decimal equivalent.
  • Level3
    See how to build an advanced client server chat like program that allows multiple connections (like IRC) using the Winsock control.
  • Level2
    Would you like to write your own chat or IM program? This sample demonstrates how you can use the VB6 Winsock control to build a simple client server application.
  • Level2
    Every great game keeps tracks of users high scores and displays them. See how to do just that.
  • Level4
    Ever wanted to write your own scripting language? While this source will get you started. See how to use dynamic classes to create a runtime class browser.
  • Level2
    Take a look at this example code to see how to read data from windows resource files and use it in DirectX - specifically Direct Draw.
  • Level2
    See how we can build of off Visual Basic 6's way of storeing data and information in .frx files using property bags.
  • Level3
    Use the binary AND and OR operators to keep track of game character attributes.
  • Level3
    See how to do all sorts of things with bitmap files. This code demonstrates how to use and manipulate windows bitmaps at the lowest level.
  • Level2
    See how to use binary operators to store a characters attributes in a binary way to use less memory for your game development
  • Level4
    This source demonstrates how to map 3d coordinates in a way that allows the user to click on them with his mouse using DirectX 8.
  • Level3
    Instead of putting a frame cap on your game this source code shows you how to get your max FPS by using Time Based Modeling.
  • Level3
    If you want enemies to seek after your player (like ghosts after pacman) or you want enemies to run from your player (like when pacman eats a pill) then you must master the AI seeking and fleeing algorithms.
  • Level3
    In any good game we must detect when objects have collided. This turns out to be pretty simple. See how to do both rectangular and circular collision detection.
  • Level2
    See an example of how we can use XOR functions to do simple encryption on strings. Very useful for simple game high score encryption.
  • Level3
    There are times in game development where we need to have a bunch of objects behave like a flock. With a little math we can simulate the behavior of a flock of animals.
  • Level1
    Have you ever wanted to display your program in the system tray by the clock. This code demonstrates how you can do just that using Windows API calls only.
  • Level3
    This sample demonstrates how to call the FlashWindow Win32 API from within your program. Use this to get the end user's attention.
  • Level2
    See an example of menus being added dynamically.It does this simply by using menu control arrays.
  • Level2
    A full working application that mimics a cellphone touch-pad. It demonstrates how to use control arrays. It also uses the timer control.

If you enjoyed this post, subscribe for updates (it's free)