Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Syntax Colouring for VBScript in Visual Studio 6

0.00/5 (No votes)
31 Dec 2001 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here