PDA

View Full Version : Invalid procedure call or argument: 'Left'



havey
01-14-2004, 07:39 AM
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Left' at the line:
strInList = Left(strInList, len(strInList)-1)

any ideas?

Dim arrCuisines, strInList

arrCuisines = array("AFRICAN","CARIBBEAN","CHINESE","CONTINENTAL",....")

For each cuisine In arrCuisines
If Request.Form(cuisine) = "true" Then
strInList = strInList & "'" & cuisine & "',"
End If
Next

strInList = Left(strInList, len(strInList)-1)

sql = "SELECT * FROM logbook WHERE cusine IN (" & strInList & ")"

glenngv
01-14-2004, 07:55 AM
Why not just use Join()?

strInList = Join(arrCuisines, "','")
sql = "SELECT * FROM logbook cusine IN ('" & strInList & "')"

The reason you're getting the error is probably the variable strInList is empty (the request.form condition evaluated to false) which make the call to Left() like this:

strInList = Left("", -1)

obviously a less than zero length is invalid.

oracleguy
01-14-2004, 04:31 PM
glenngv,

I'd bet that is what the error is coming from.

I noticed that you are checking if the form element in the variable name cuisine is being evaluated, is it supposed to have quotes or actually be a variable.

glenngv
01-15-2004, 02:14 AM
The quoted "true" is correct. Values retrieved from Request collections are all strings.

Analyzing the code again, I think my suggestion of using Join() was wrong. Here's the correct code:


arrCuisines = array("AFRICAN","CARIBBEAN","CHINESE","CONTINENTAL", "....")

For each cuisine In arrCuisines
If Request.Form(cuisine) = "true" Then
strInList = strInList & "'" & cuisine & "',"
End If
Next

if strInList<>"" then
strInList = Left(strInList, len(strInList)-1)
sql = "SELECT * FROM logbook WHERE cusine IN (" & strInList & ")"
end if

nhaus
04-09-2014, 09:36 AM
Hello
Any idea, why I am getting this error?:

(135, 4) Microsoft VBScript runtime error: Invalid procedure call or argument: 'Left'

alykins
05-14-2014, 02:06 PM
@nhaus
Please post a new thread with the code you need help with. This thread is from 2004 and we have no idea what code you are using.