/    Sign up×
Community /Pin to ProfileBookmark

Cannot use parentheses when calling a Sub

Hi folks,

I’m working on a relatively simple feature to update some content in a database – a time-stamp, specifically. However, every time I try to make the call, I get the following error:

[code]Microsoft VBScript compilation error ‘800a0414’

Cannot use parentheses when calling a Sub

/datetest.asp, line 31

UpdateContactBK(StrContactNo,ObjTrack,pd(DAY(date()),2) & ” ” & MonthName(2,true) & ” ” & YEAR(date()),”TrainAcc”)
——————————————————————————————————————^[/code]

The corresponding code:

[code]
<&#37;
Function pd(n, totalDigits)
if totalDigits > len(n) then
pd = String(totalDigits-len(n),”0″) & n
else
pd = n
end if
End Function

Function returnDateString()
Dim lastAccDate
lastAccDate = pd(DAY(date()),2) & ” ” & MonthName(2,true) & ” ” & YEAR(date())
returnDateString = lastAccDate
End Function

Response.Write(returnDateString())

[color=red]UpdateContactBK(StrContactNo,ObjTrack,returnDateString(),”TrainAcc”)[/color]
%>
[/code]

As you’ll see, the Response.Write call is perfectly fine, and correctly prints the date in MM-DD-YYYY format. However, the compiler doesn’t seem to like the red line. I’ve read [url]http://blogs.msdn.com/b/ericlippert/archive/2003/09/15/52996.aspx?PageIndex=2#comments[/url] amongst other blogs, but to no avail. I’d like some other opinions.

[i] Note: UpdateContactBK method omitted, as it isn’t relevant. [/i]

Thanks, all.

to post a comment

4 Comments(s)

Copy linkTweet thisAlerts:
@fredmvauthorFeb 08.2012 — As un-intuitive as it is, assigning it to a variable seems to work.

e.g.

<i>
</i>test123 = UpdateContactBK(StrContactNo,ObjTrack,pd(DAY(date()),2) &amp; " " &amp; MonthName(2,true) &amp; " " &amp; YEAR(date()),"TrainAcc")
Copy linkTweet thisAlerts:
@fredmvauthorFeb 08.2012 — http://blogs.msdn.com/b/ericlippert/archive/2003/09/15/52996.aspx[/QUOTE]

If you had actually read my post, you'd have seen that I already read that article. In any case, the solution I arrived at wasn't even discussed in the article.


ASP Classic/VBScript are clunky and terrible, I must say.
Copy linkTweet thisAlerts:
@nap0leonFeb 11.2012 — Did you try following the instructions that the error message gave you (removing the parentheses? Every time I get that message, I remove the parens from the function call and it works like a champ.

<i>
</i>UpdateContactBK StrContactNo,ObjTrack,returnDateString(),"TrainAcc"
×

Success!

Help @fredmv spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...