Results 1 to 6 of 6

Thread: ASP Mid Function Error

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    3

    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

  2. #2
    Member dorbian's Avatar
    Join Date
    Apr 2002
    Location
    amsterdam - netherlands
    Posts
    62

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    3

    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.

  4. #4
    Member dorbian's Avatar
    Join Date
    Apr 2002
    Location
    amsterdam - netherlands
    Posts
    62

    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

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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:
    1. i = Len(strFullPath)
    2. Do Until Left(str, 1) = "\" Or Left(str, 1) = ":" Or i <= 1
    3.   str = Mid(strFullPath, i - 1)
    4.   i = i - 1
    5. Loop
    or this:
    VB Code:
    1. For i = Len(strFullPath) To 2 Step -1
    2.   If Left(str, 1) = "\" Or Left(str, 1) = ":" Then Exit For
    3.   str = Mid(strFullPath, i - 1)
    4. Next i

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    3

    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
  •  



Click Here to Expand Forum to Full Width