How to Convert QBasic to Visual Basic

By Mark Keller

The simple QBasic programming language was shipped with every DOS computer in the 1980s and early '90s. Microsoft's Visual Basic language has since replaced it, allowing hobbyists to write programs that use the Windows interface instead of the command line. The two languages are largely compatible, however, allowing you to easily convert your QBasic code to the more current language.

Step 1

Rename the file extension of your QBasic program from ".bas" to ".txt" and ignore any warning messages.

Step 2

Open Visual Basic and double-click "Button" in the toolbox to add it to your form. Change the button's text property in the right panel to "Start."

Step 3

Double-click the button to open its code page. Select "Edit" > "Insert File" and choose your QBasic code text file. This will make your QBasic code run when the user clicks the Start button.

Step 4

Modify the QBasic code to conform to Visual Basic standards. Note the presence of any lines that look like the following:IF INKEY$ = A THEN BEEPINPUT "Enter a number"; ZReplace them with the following lines of Visual Basic code, customizing variable names and prompt messages as necessary:If KeyAscii = 65 ThenBeepEndIfZ = InputBox("Enter a number")Remove any "SCREEN" declarations and replace the "WINDOW" command with "Scale."

Step 5

Click the green arrow on the toolbar to run the program. If everything works properly, click the "Start" button to execute. If you receive an unrecognized command error, consult the Visual Basic documentation to find the proper replacement to use in place of the outdated QBasic command.