Visual Basic Sample Program

Here are some Visual Basic sample program you can download to get a little familiar with the programming methods and concepts before you start building Visual Basic applications.

The first sample program is a simple application that merges two text files. The download is available in 2 versions - Visual Basic 6.0 and Visual Basic 2008.

Visual Basic 6.0 Sample Program

This application contains a single main form with 2 text boxes for user input. It uses the Common Dialog Box control to help select text files. The main file merge code uses the Open File methods to open the source text files and using the same method creates a new merged file in the application folder.

Download the Visual Basic 6.0 Sample

Visual Basic 2008 Sample Program

This .NET application contains a single main form with 2 text boxes for user input. It uses the Open File Dialog control provided by .NET framework for selection of text files. The main file merge code uses System.IO.StreamReader and System.IO.StreamWriter objects to read from source files and create a new merged file in the application folder.

Download the Visual Basic 2008 Sample

The second part below has samples for automation that are done using visual basic in Excel, Access and Script environments.

Excel Visual Basic Sample Program

This simple Excel file has a RenameSheets macro that will rename all the worksheets in the workbook. All worksheets are renamed using the value present in cell A1 of the respective worksheet. The macro uses ThisWorkbook.Sheets collection to cycle through the worksheets and do the renames.

Download the Excel Visual Basic Sample

Access Visual Basic Sample Program

This Access database has two tables and a form. The goal of the database is to spilt orders into sub-orders according to a percentage value provided by the user. The first table Original_Orders contains all the orders that need to be split. The Sub_Orders table will contain the resulting orders after processing. A form Sub_Orders_Creator is used to interact with the user, to take in the percentage input and display process messages.

Download the Access Visual Basic Sample

Visual Basic Script Sample Program

This script file is used to login to a FTP site and download a file. It uses a Scripting.FileSystemObject to create a FTP batch text file. The WScript.Shell object is then used to run the FTP command with the FTP batch file.

Download the VBScript Sample

The sample programs here are simple automation examples to give you a brief idea on how Visual basic can be used across different platforms. As for the beginner these samples are useful in exploring different ways of programming using VB. See sample codes to checkout code snippets from the sample programs mentioned above.

Back to Visual Basic Download