Tuesday, March 2, 2010

How to Add Lines to a VBS File

Visual Basic Script (VBS) is a scripting language made for Windows. Most Windows programs use VBS in some way or another, so if you are a programmer using Windows, familiarizing yourself with Visual Basic is a good idea. You can edit a VBS file with any text editor, including Notepad.

Instructions
  1. Step 1

    Go to "Start," "Programs," "Accessories," "Notepad" to open Notepad.

  2. Step 2

    Go to "File," "Open" and navigate to the location of your VBS file. Click "Open." You will see a whole bunch of VBS code.

  3. Step 3

    At the top of the file, select some whitespace, and copy-paste the following Visual Basic code:
    MsgBox("Hello World")

  4. Step 4

    Go to "File," "Save as..." and save the file with a different name, but keeping the ".vbs" suffix. For example, you could name your file "newScript.vbs" and click "Save."

  5. Step 5

    Open the Command Prompt by going to "Start," "Programs," "Accessories," "Command Prompt." Navigate to the directory where you saved your VBS file by typing "cd C:\Your Directory Name Here" and hitting "Enter."

  6. Step 6

    Type the name of your new VBS script and hit "Enter" to run the script. The script should run as it did (before you added your line of code), only this time a message box will pop up saying "Hello, World!"

No comments:

Post a Comment