Click here to Skip to main content
Click here to Skip to main content

Syntax Colouring for VBScript in Visual Studio 6

, 31 Dec 2001
Rate this:
Please Sign up or sign in to vote.
A simple registry modification to make Visual Studio apply syntax colouring to VBScript files.

Introduction

Visual C++ does not provide nice features such as syntax colouring for many languages other than C++ itself. One of these "poorer relation" languages is VBScript. With the increasing availability and usefulness of VBScript since the original release of Visual Studio 6, it may be quite desirable to use VBScript for purposes such as creating build scripts. However, it can be quite difficult to read yet another programming language without syntax colouring to lend a helping hand. As a result, it may be quite discouraging to new users to dabble with VBScript as part of a Visual C++ project.

There is a simple solution for this problem!

Modifying the Registry

Although Visual Studio doesn't provide syntax colouring for .vbs files, it does provide syntax colouring for its own VBScript macro files, which have the extension .dsm. It turns out that adding VBScript syntax colouring for another type of file is as simple as adding the file's extension to a list in the registry.

First of all, close Visual Studio before starting, as it will subsequently repair any registry modifications that you make while it is open. Then open a registry editor such as Regedit and find the registry key HKCU\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\VBS Macro. It contains a REG_SZ (string) value called FileExtensions. This value will already contain "DSM"; if you modify it to read "DSM;VBS" then restart Visual Studio, VBScript files with the extension .vbs will now benefit from the same syntax colouring as Visual Studio macro files.

Limitations

This registry modification adds no new functionality to Visual Studio, so the syntax colouring will suffer from any limitations already found when using .dsm files. This includes incomplete colouring of some well-established syntax (for example, Boolean operators such as And and Or are not coloured), and of course the syntax colouring will not recognise more recent additions to Windows Scripting. Using this functionality to colour XML-based Windows Script Files (.wsf) will only be a partial success! However, the syntax colouring available through this method does add considerably to the readability of VBScript code despite these limitations.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Gavin Greig
Web Developer
United Kingdom United Kingdom
Gavin Greig has been a developer with Insights Learning & Development Ltd. in Dundee, Scotland since 1996, using Visual C++ and the MFC.
 
He is a graduate of St. Andrews University, where he studied Physics and Electronics, and has a Computer Science M.Sc. and a Ph.D. from Dundee University.
 
He has also worked as a MUMPS developer in the British National Health Service, and recommends that you have a look at MUMPS yourself to see a perfect example of how programming languages should not be done.

Comments and Discussions

 
GeneralBest one yet PinmemberErgin Salih30-Sep-02 17:20 
GeneralNice One Gavin! PinmemberDavy Mitchell3-Jan-02 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 1 Jan 2002
Article Copyright 2002 by Gavin Greig
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid