1

My code is pulling from a data cells that lists multiple file paths and use semicolons " ; " as the separator. After spliting the data and placing it into an array, I need to remove the semicolons. otherwise my file paths are invalid when they enter the loop.

To clarify: My code works when there is only one file path in the data cell and dies once it hits a cell with multiple paths because of the ";"

ANY HELP would be much appreciated.

My code is the following:

<%
strValue = RS("ATTACHMENTS")
strAryWords = Split(strValue, ";")

' - strAryWords is now an array
For i = 0 to Ubound(strAryWords)
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set fileObject = fso.getFile(strAryWords(i))

    Response.Write "<TH><TR align=left><TD>" & strAryWords(i) &"  "& fileObject.Size &"  "&"<img src=images/up.gif><BR></TD></TR>"

    Set fileObject = Nothing
    Set fso = Nothing  
Next
%>
8
  • Please state which language you are using (visual basic?), and tag the question accordingly. Commented Jan 17, 2009 at 15:32
  • added 'vb.net beginner' tags. Commented Jan 17, 2009 at 15:33
  • Looks like Classic ASP unless my eyes deceive me :) Commented Jan 17, 2009 at 15:34
  • Sebastian why did you retag VB.NET when the person that asked the question retaged VBScript? Commented Jan 17, 2009 at 15:38
  • It is not vb.net. It is or Vb 6 or Vbscript Commented Jan 17, 2009 at 15:39

1 Answer 1

1

If the problem is strValue has a trailing ';', change your code to this:

strValue = RS("ATTACHMENTS")
strAryWords = Split(strValue, ";")


' - strAryWords is now an array
For i = 0 to Ubound(strAryWords)
    If strAryWords(i) <> "" Then
        Set fso = Server.CreateObject("Scripting.FileSystemObject")
        Set fileObject = fso.getFile(strAryWords(i))

        Response.Write "<TH><TR align=left><TD>" & strAryWords(i) &"  "& fileObject.Size &"  "&"<img src=images/up.gif><BR></TD></TR>"

        Set fileObject = Nothing
        Set fso = Nothing
    End If
NEXT
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.