Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2003, 01:20 PM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBScript Functions

Hello,

I'm trying to write a validation function to replace single quotes with something that is SQL friendly,

e.g.

Function myFunction(str)
    Replace(str, "'", "#39;")
    myFunction = str
End Function

But I'm getting a "cannot use parentheses when calling a sub error". Advice please?



 
Old September 4th, 2003, 01:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When calling myFunction in your code, do not use the parenthesis

instead of something like
Code:
<BODY onsubmit="vbscript:myFunction(str)">
USE
Code:
<BODY onsubmit="vbscript:myFunction str">
Chris
 
Old September 4th, 2003, 01:37 PM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.

There was also a problem with my function. It should have been written:

Function myFunction(str)
    myFunction = Replace(str, "'", "#39;")
End Function

 
Old September 4th, 2003, 01:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you are correct. I did not even look at your function. Sorry. I have just seen the error you specified many times in my own work, so I just wrote back what I knew on it. I guess I should have looked at your function a little closer as well. Glad you discovered and fixed it.

Chris




Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel functions in vbscript blrao VBScript 0 April 12th, 2008 04:46 AM
Functions czambran BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 13 July 11th, 2006 06:33 PM
functions xelepi PHP How-To 1 March 10th, 2006 02:59 AM
Functions Meg Intro Programming 1 January 23rd, 2006 01:03 PM
Help with Functions megabytes C# 1 August 7th, 2003 12:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.