Avatar of pborregg
pborregg
Flag for United States of America asked on

type mismatch error filter vbscript in ASP

Here's the Code:

            dim a(2)
            dim b
            
            a(0) = "Microsoft"
            a(1) = "Adobe"
            
            b=Filter(a,"i")


I want to SIMPLY Filter all items in a FOR NEXT loop to be either DOC or PDF.

Here's what I wrote:

     'Display a list of files.
     for each item in folder.Files
       url = MapURL(item.path)

******************************* This is ONLY the code I need to have working please.

            dim a(2), b
            a(0) = "Microsoft"
            a(1) = "Adobe"
            
            b=Filter(a,item.Type,true,1)

********************************

              Response.Write("<li><input id='chooseItem' name='chooseItem' type='checkbox' value='"+item.Name+"' onmouseup='javascript:listItems(this.value)'/><a href=""" & url & """ target='_blank'>" & item.Name & "</a> - " _
                   & item.Size & " bytes, " _
                   & "last modified on " & item.DateLastModified & "." _
                   & "</li>" & vbCrLf)
            
     next

I found the EXAMPLE here--->>> http://www.w3schools.com/vbscript/func_filter.asp

PROBLEM:

I keep getting TYPE MISMATCH on 'a'.

WHY?

I'm developing in DREAMWEAVER and writing an ASP Page.

THIS IS SUPPOSED TO WORK.... Anyone have any thoughts?

Peter
ASP

Avatar of undefined
Last Comment
Cem Türk

8/22/2022 - Mon
WMIF

i wonder if its getting confused with an extra row in the array.  try like this:

          dim a(1), b
          a(0) = "Microsoft"
          a(1) = "Adobe"
         
          b=Filter(a,item.Type,true,1)
pborregg

ASKER
c:\.......\content\docs <-- Hidden for security Reasons.
DOCS - 2 files, 9 Sub directories, 26509 KB total.
C:\........\content\docs\about_mema <-- Hidden for security Reasons
ABOUT_MEMA - 5 files, 1913 KB total.
MEMA_Org_062006_1.doc - 494592 bytes, last modified on 6/15/2006 3:19:47 PM.
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'a'

/pio/article_list.asp, line 66


Nope this is what I get in IE 7
Cem Türk

hello,

i am not very experienced with ASP, but it seems that you should pass the array elements instead of whole array in the following code;

b=Filter(a,item.Type,true,1)

so

b=Filter(a(0),item.Type,true,1)

can work (in my opinion of course)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
pborregg

ASKER
ABOUT_MEMA - 5 files, 1913 KB total.
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Filter'

/pio/article_list.asp, line 70
 

No Cem_turk... Get this error now.
WMIF

lets do this and see exactly what item.type is returning:

          dim a(2), b
          a(0) = "Microsoft"
          a(1) = "Adobe"
          response.write item.type
          response.end()
          b=Filter(a,item.Type,true,1)
ASKER CERTIFIED SOLUTION
WMIF

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Cem Türk

your code declares a again and again in the for loop can that be the problem?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
pborregg

ASKER
To WMIF

This is what I get now

ABOUT_MEMA - 5 files, 1913 KB total.
Microsoft Word Document

and with your enhancement:

ABOUT_MEMA - 5 files, 1913 KB total.
-->Microsoft Word Document<--

No files though... Progress

To Cem Turk

BINGO!!!! YIPPIE!!! I moved the DIM statement ABOVE the LOOP statement and it works...

Ok, both of you, it's still not filtering because I'm getting html, jpegs, etc... I simply want DOCs and PDFs

Now we're on the right track
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.