Skip to main content
Email Password   helpLost your password?

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.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralBest one yet Pin
Ergin Salih
18:20 30 Sep '02  
GeneralNice One Gavin! Pin
Davy Mitchell
5:23 3 Jan '02  


Last Updated 31 Dec 2001 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009