How to Write Simple Visual Basic Codes

By Misty S. Bledsoe

Writing simple Visual Basic computer code is a matter of utilizing the prebuilt code pieces that come as a part of Visual Basic Express or Visual Studio .NET developer environments. Visual Basic Express is a free download available from Microsoft's website, and Visual Studio .NET is the full software developer environment with all the bells and whistles a programmer would need to build complex software applications. If you are just starting out and don't wish to pay for the full Visual Studio .NET environment, simply download and install Visual Basic Express.

Things You'll Need

  • Visual Basic Express installed on a PC
  • Visual Studio .NET installed on a PC (optional)

Step 1

Open your developer environment. You will see a window with three columns. In the upper left of the middle panel, you will see a tab labeled "Recent Projects." Locate the last option of "Create" and click on the word "Project" directly to the right of it.

Step 2

Click on "Windows Form App" in the new window that will pop up. This will be the easiest type of project to work on for learning to write simple Visual Basic codes. Type in the name of your new application in the "Name" box below the window and hit "OK."

Step 3

Click on the word "View" across menu choices at the very top of the page. Choose "Tool Box." A list of prebuilt items such as buttons, graph inserts, calendars and text boxes will appear. Take a moment to look through the list to familiarize yourself with your options.

Step 4

Click on the word "Button" in the toolbox list. Hold the mouse key down, drag it over to the blank form in the middle of the screen and let go. Right-click on the button. Scroll down and choose "Properties." The properties screen will appear to your right with the "Text" field already highlighted. Change the text from "Button 1" to "Click Here." Hit "Enter" when you are finished.

Step 5

Double-click on the button you put on the form. This will open the code page where you will add simple Visual Basic code to make the button do something. The cursor will be between "Private Sub" and "End Sub." Type "msgbox ("Thanks for clicking on me!")" without the outer quote marks.

Step 6

Click on "File" on the top menu item and choose "Save All." You will be prompted to choose a location to save your new application to on your hard drive. Click "Save."

Step 7

Press the "F5" key on your keyboard to run your application. A box will pop up on the screen with the button exactly as you made it. Click on the button you made; a new window should pop up in the middle of the screen that says, "Thanks for clicking on me!"

Step 8

Close your developer environment when you are finished.