Click here to Skip to main content
6,294,871 members and growing! (17,779 online)
Email Password   helpLost your password?
General Programming » Programming Tips » General     Intermediate

Syntax Colouring for VBScript in Visual Studio 6

By Gavin Greig

A simple registry modification to make Visual Studio apply syntax colouring to VBScript files.
VBScript, VC6Win2K, WinXP, Visual Studio, Dev
Posted:31 Dec 2001
Views:40,857
Bookmarked:14 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
15 votes for this article.
Popularity: 5.18 Rating: 4.41 out of 5
1 vote, 14.3%
1

2
1 vote, 14.3%
3
2 votes, 28.6%
4
3 votes, 42.9%
5

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

About the Author

Gavin Greig


Member
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.
Occupation: Web Developer
Location: United Kingdom United Kingdom

Other popular Programming Tips articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 2 of 2 (Total in Forum: 2) (Refresh)FirstPrevNext
GeneralBest one yet PinmemberErgin Salih18:20 30 Sep '02  
GeneralNice One Gavin! PinmemberDavy Mitchell5:23 3 Jan '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 31 Dec 2001
Editor: Andrew Peace
Copyright 2002 by Gavin Greig
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project