CoverYourASP --> Snippets

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
99 active users
24 visitors today
34 pages today
how is this done?
Tools I use

Copyright © 1999-2016 James Shaw.
All rights reserved.

RSS submissions

Now open source with SourceForge!

"Snippets" are mini-articles - they allow me to very quickly add answers to your frequently asked questions, and add brief explanations for topics that you've searched for without success. So, everytime you send an email or perform a search, chances are a new snippet will be the result!

11 Jan: Porting my JScript code to VBScript

I'm glad Robert Egan wrote to me recently, because his question made me aware that I don't make it obvious enough that my code is all JScript, not the more common VBScript. Here's his question:

Hope you can help with this question of mine, I've downloaded your site code, and I'm looking to use a portion of it in a site I'm building. However, when I use your code I get:

Microsoft VBScript compilation error '800a0401'

Expected end of statement
/../header.asp, line 4
Application.Lock ( );

^ pointing to ;

What do I do to get this to function correctly James?

I don't get asked this much, but perhaps that's because most people just give up, think "crappy code" and move on!

Since I converted some of my code to VBScript recently I thought I'd share my findings - you'll see that it isn't that difficult to port my code to VBScript. (To see why you may want to work in one language or the other, see Why use JavaScript instead of VBScript?)

Here's what I did:

• surround strings with " rather than '
• change // before a comment to '
• change if (..) {..} else {..} to If .. Then .. Else .. End If - note the ( ) { } all disappear. 'one-line' If statements still need the End If
• change for (i=0; i<3; i++) {..} to For i=0 To 2 .. Next
• change while (!oRS.EOF) {..} to While 0 = oRS.EOF .. Wend
• change return a; to nameoffunction = a, followed by Exit Function
• change } at end of function with End Function
• remove all remaining { } ; characters

This isn't a complete list, but it'll get you a long way. I recommend making a quick pass through the code first making these changes, then running the page. The browser will show you what still doesn't make sense. I'll update this page as I remember other necessary changes.

Featured sponsor
My favorite resources

Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!

New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!