//  home   //  advanced search   //  news   //  categories   //  sql build chart   //  downloads   //  statistics
ASP FAQ Tutorials

   8000XXXX Errors
   ASP.NET 2.0
   Classic ASP 1.0
      COM / ActiveX Components
      General Topics
      Date/Time Routines
      Email Scripts & Info
      Files/Directories & FSO
   General Concepts
   Search Engine Optimization (SEO)

Contact Us
Site Map



ASP FAQ Tutorials :: Classic ASP 1.0 :: Files/Directories & FSO :: Why do I get 'Invalid procedure call or argument'?

Why do I get 'Invalid procedure call or argument'?

This often happens because you used a VBScript "friendly name" constant in place of its integer equivalent. Visual Basic understands these friendly names, such as FileSystemObject's 'forAppending' and 'forWriting' constants. 
An easy solution is to add this line to any include files you use in every page (or else add it at the top of every page, if you don't have a common header in your application): 
    Const ForReading = 1, ForWriting = 2, ForAppending = 8 

Another possible cause is trying to use a string operation (like Mid(), InStr(), Left() or Right()) on a NULL value. So for example: 
    response.write Left(rs("column"), 10) 
Should be: 
    if len(rs("column")) > 0 then 
        response.write Left(rs("column"), 10) 
        response.write " " 
    end if 
If you're having these problems with NULL values coming out of a database, see Article #2150

Another possibility is that you are coming over from JavaScript, or otherwise think that string lengths are 0-based. The following code sample will cause this error: 
    str = "foo" 
    response.write Mid(str, 0, 1) 
Similarly, passing a starting argument of 0 to the Instr() function will cause the same error. To solve this problem, always start at 1 for string parsing in VBScript. 

Still one more possibility is that you have unexpected characters in an FSO writeline call. I recently came across this when using MSXML to write out contents of dynamic ASP files into static HTML files. I had this: 
    set fs = fso.CreateTextFile("blat.htm", true) 
    fs.writeline xmlHTML 
When I ran this code, I received the above error. When I added the unicode format designator, as follows, everything worked fine: 
    set fs = fso.CreateTextFile("blat.htm", true, -1
    fs.writeline xmlHTML 

Related Articles

Can I include a file in both server-side and client-side script?
Can I read / write a user's file without a prompt?
Can I rename a file using FileSystemObject?
Could I get some help working with files using FileSystemObject?
How do I avoid 'the red x' when an image is missing?
How do I change the modified time of a file?
How do I create / manipulate images from ASP?
How do I dynamically include files?
How do I find the owner, author, and other properties of a file?
How do I get a list of a folder's subfolders?
How do I get the name of the current URL / page?
How do I prevent people from 'leeching' my CSS or JS files?
How do I prevent people from 'leeching' my images?
How do I retrieve a random file from a given folder?
How do I send the correct filename with BinaryWrite?
How do I sort a list of files?
How do I use FileSystemObject to create a file on the client?
Why do I get 'Disk not ready' errors with FileSystemObject?
Why do I get 'Path not found' errors with Scripting.FileSystemObject?
Why do I get 'Permission Denied' errors with FileSystemObject?
Why do I get 800A0034 errors?
Why do I get 800A003E / Input past end of file errors?
Why do I get 800A0BBA errors?
Why do I get 800A0BBC errors?
Why do I get an 'Invalid Path Character' error?
Why do I get permissions errors after upgrading to Windows XP?
Why does FileSystemObject hang all of a sudden?
Why is 'the operation completed successfully' an error message?



Created: 1/24/2001 | Last Updated: 11/2/2003 | broken links | helpful | not helpful | statistics
© Copyright 2006, UBR, Inc. All Rights Reserved. (309)


Copyright 1999-2006, All rights reserved.
Finding content
Finding content.  An error has occured...