Technology Programming

How to Write Simple Visual Basic Codes

    • 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.

    • 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."

    • 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.

    • 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.

    • 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.

    • 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."

    • 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!"

    • 8). Close your developer environment when you are finished.



Leave a reply