Microsoft Vbscript Compilation Error 800a0414
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about
Cannot Use Parentheses When Calling A Sub In Qtp
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges cannot use parentheses when calling a sub msgbox Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other.
Cannot Use Parentheses When Calling A Sub Replace
Join them; it only takes a minute: Sign up Can't Use Parentheses When Calling a Sub - VBScript up vote 0 down vote favorite I'm writing this code in VBScript, which I haven't used before in my life. I cannot use parentheses when calling a sub asp wrote this: Replace (strContent, st, arr (k,i), 1) And it gives me a "Can't Use Parentheses When Calling a Sub" problem. Can anyone please help? I've tried searching online but nothing helped. Thank you! vbscript parentheses share|improve this question asked Jul 30 '13 at 10:59 Neta 3771418 1 see stackoverflow.com/a/13622374/603855 –Ekkehard.Horner Jul 30 '13 at 11:34 Saw that, didn't quite understand what the solution is... –Neta Jul 30 '13 at 12:47 2 This is function vbscript so popular issue for new in VBScript, Replace is Function that return result you s'd assign to variable, like strResult=Replace(...) –Panayot Karabakalov Jul 30 '13 at 13:13 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted Found the answer thanks to Panayot Karabakalov. We tried using a Call and doing it without parentheses: Replace strContent, st, arr (k,i), 1 But nothing worked. The solution eventually was: strContent = Replace (strContent, st, arr (k,i), 1) Thank you everyone for the quick and helpful responses! You guys never let us down. share|improve this answer answered Jul 31 '13 at 5:18 Neta 3771418 Thanks! This was driving me crazy... –Mentok Apr 28 '14 at 21:05 add a comment| up vote 1 down vote See this article from Eric Lippert. Basically, when you use a procedure or function like this: Foobar arg1, arg2, arg3 you must not use parentheses around the argument list. When you use the Call keyword or use the return value of a function in an assignment or a condition, then you must use parentheses around the argument list, e.g.: Call Foobar(arg1, arg2, arg3) result = Foobar(arg1, arg2, arg3) If Foobar(arg1, arg2, arg3) Then ... End If share|improve this answer answered Jul 30 '13 at 13:38 Ansgar Wiechers 86.8k1165104 We tried with a "Call" and without parentheses as in your first example a
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before
Expected End Of Statement
you can post: click the register link above to proceed. To vbscript function return start viewing messages, select the forum that you want to visit from the selection below. Results 1 to
Vbs Expected End Of Statement
5 of 5 Thread: Cannot use parentheses when calling a Sub Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to http://stackoverflow.com/questions/17945213/cant-use-parentheses-when-calling-a-sub-vbscript Hybrid Mode Switch to Threaded Mode 02-08-2012,12:23 PM #1 fredmv View Profile View Forum Posts Moderator Join Date Jul 2003 Location Boston Area, Massachusetts Posts 3,489 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 http://www.webdeveloper.com/forum/showthread.php?256509-Cannot-use-parentheses-when-calling-a-Sub 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") ------------------------------------------------------------------------------------------------------------------^ The corresponding code: Code: <% 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()) UpdateContactBK(StrContactNo,ObjTrack,returnDateString(),"TrainAcc") %> 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 http://blogs.msdn.com/b/ericlippert/...dex=2#comments amongst other blogs, but to no avail. I'd like some other opinions. Note: UpdateContactBK method omitted, as it isn't relevant. Thanks, all. Last edited by fredmv; 02-08-2012 at 12:39 PM. Moderator @ WebDeveloper.com Reply With Quote 02-08-2012,01:23 PM #2 yamaharuss View Profile View Forum Posts Visit Homepage V8 Rider Join Date Jan 2008 Location Florida Posts 1,227 http://blogs.msdn.com/b
LippertSeptember 15, 200356 Share 0 0 Every now and then someone will ask me what the VBScript error message "Cannot use parentheses when calling a Sub" means. I always smile when I hear that question. I tell people that the https://blogs.msdn.microsoft.com/ericlippert/2003/09/15/what-do-you-mean-cannot-use-parentheses/ error means that you CANNOT use PARENTHESES when CALLING a SUB -- which word didn't you understand? Of course, there is a reason why people ask, even though the error message is perfectly straightforward. Usually what https://www.cyscape.com/support/kb/XcIBViewItem.asp?ID=444 happens is someone writes code like this: Result = MyFunc(MyArg) MySub(MyArg) and it works just fine, so they then write MyOtherSub(MyArg1, MyArg2) only to get the above error. Here's the deal: parentheses mean several different things cannot use in VB and hence in VBScript. They mean: 1) Evaluate a subexpression before the rest of the expression: Average = (First + Last) / 2 2) Dereference the index of an array: Item = MyArray(Index) 3) Call a function or subroutine: Limit = UBound(MyArray) 4) Pass an argument which would normally be byref as byval: Result = MyFunction(Arg1, (Arg2)) ‘ Arg1 is passed byref, arg2 is passed byval That's confusing enough cannot use parentheses already. Unfortunately, VB and hence VBScript has some weird rules about when #3 applies. The rules are 3.1) An argument list for a function call with an assignment to the returned value must be surrounded by parens: Result = MyFunc(MyArg) 3.2) An argument list for a subroutine call (or a function call with no assignment) that uses the Call keyword must be surrounded by parens: Call MySub(MyArg) 3.3) If 3.1 and 3.2 do not apply then the list must NOT be surrounded by parens. And finally there is the byref rule: arguments are passed byref when possible but if there are “extra” parens around a variable then the variable is passed byval, not byref. Now it should be clear why the statementMySub(MyArg) is legal but MyOtherSub(MyArg1, MyArg2) is not. The first case appears to be a subroutine call with parens around the argument list, but that would violate rule 3.3. Then why is it legal? In fact it is a subroutine call with no parens around the arg list, but parens around the first argument! This passes the argument by value. The second case is a clear violation of rule 3.3, and there is no way to make it legal, so we give an error. These rules are confusing and silly, as th
After selecting the properties for BrowserHawk to log in my database, it generated ASP code for me to use. However this code results in the following error: Microsoft VBScript compilation error '800a0414' Cannot use parentheses when calling a Sub How can I resolve this? A Some versions of ASP do not accept parenthesis when passing parameters to methods, while other versions (such as ASP.NET) require this. If you received the above error you can resolve it simply by removing the set of parenthesis which surrounds the parameters being passed to the SetExtProperties Method. For example, instead of: bhObj.SetExtProperties("ActiveXEnabled, BrowserBuildWidthAvail", false) Use: bhObj.SetExtProperties "ActiveXEnabled, BrowserBuildWidthAvail", false FAQHome| SearchFAQ| ShowNewItems| AskaFAQ| NotifyMe| MostPopular Home | Products | Company | Support | Developer | Pricing & Ordering | Downloads | Search Copyright © 1994-2015 cyScape, Inc. All Rights Reserved. ()