Link to home
Start Free TrialLog in
Avatar of pborregg
pborreggFlag 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
Avatar of WMIF
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)
Avatar of 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
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)
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.
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
Avatar of WMIF
WMIF

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
your code declares a again and again in the for loop can that be the problem?
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial