|
-
May 14th, 2005, 08:24 AM
#1
Thread Starter
New Member
ASP Mid Function Error
Good Morning.
I am fairly new to ASP but have coded in VB, Access and Oracle before. I THOUGHT this was a basic function but ASP seems to be burping on me when I execute it. I am going to include the entire ASP page to see if there is something I am missing other than the function...
<!--#include file="../dbinclude.asp"-->
<%
Function ParseFilename(strFullPath)
dim str, i
'on error resume next
str = ""
i = Len(strFullPath)
Do Until Left(str, 1) = "\" Or Left(str, 1) = ":"
str = Mid(strFullPath, i - 1)
i = i - 1
Loop
ParseFilename = Mid(str, 2)
End Function
Conn.Execute("INSERT INTO tblPersonnel( Photo) SELECT '" & ParseFilename(request.form("image")) & "' AS Expr4, '")
%>
I am getting..
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Mid'
/membermanager/add_member.asp, line 10
On the line that says "str=Mid(strFullPath, i - 1)".
Hopefully someone can figure this out for me while I am at my son's baseball game.
Have a good morning.
Knee Deep
-
May 15th, 2005, 09:27 AM
#2
Member
Re: ASP Mid Function Error
well i did some browsing and stuff but i could only find the Mid command ina response.write, not that that should really make a difference but i can't find any work where it is being used outside it.
i asked around a bit also, they all didn't know bout it either, so maybe you have to find a different way to make it do what you are doing.
-
May 15th, 2005, 10:26 AM
#3
Thread Starter
New Member
Re: ASP Mid Function Error
Yeah, I know Dorbian...it does not make sense at ALL. I have used the Mid function in different places. I was wondering if maybe I am somehow embedding the function itself into my ASP page incorrectly...but I can't figure it out.
-
May 15th, 2005, 10:32 AM
#4
Member
Re: ASP Mid Function Error
well i found something on Mid and as it seems, you are using it wrong :S i have the link to the page, i hope it will be usefull to you.
http://www.w3schools.com/vbscript/func_mid.asp
-
May 15th, 2005, 11:54 AM
#5
Re: ASP Mid Function Error
From a VB point of view your usage of Mid is ok, but the loop it is contained in isn't.
The error you are getting occurs with Mid if the first numeric parameter is 0 or less, and you loop does not enforce a minimum value.
I would recommend either this:
VB Code:
i = Len(strFullPath)
Do Until Left(str, 1) = "\" Or Left(str, 1) = ":" Or i <= 1
str = Mid(strFullPath, i - 1)
i = i - 1
Loop
or this:
VB Code:
For i = Len(strFullPath) To 2 Step -1
If Left(str, 1) = "\" Or Left(str, 1) = ":" Then Exit For
str = Mid(strFullPath, i - 1)
Next i
-
May 15th, 2005, 11:37 PM
#6
Thread Starter
New Member
Re: ASP Mid Function Error
Excellent Si. Thanks to both of you. It's great to find a forum I can go to and get answers when I have problems. You may see me here a bit more.
Thanks again for your help.
Knee Deep
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|