Sometimes the line doesn't exists?

Results 1 to 2 of 2

Thread: Sometimes the line doesn't exists?

  1. #1
    Join Date
    Dec 1969

    Default Sometimes the line doesn't exists?

    I have file (text) that is returned from another server. My code divides the text into lines. Sometimes there&#039;s 20 lines sometimes there&#039;s only 3. My problem is if there is only 3 lines the script still looks for the lines 4 and above and errors out. Is there a way to check for how many lines are in a file? I have a little bit of the code below..<BR><BR> Set objFSO2 = _<BR> Server.CreateObject ("Scripting.FileSystemObject")<BR> Set objOpenFile2 = objFSO2.OpenTextFile(strpath2,1)<BR> reDim myarray(0)<BR> i=-1<BR> While Not objOpenFile2.AtEndofStream<BR> i=i+1<BR> Redim Preserve myarray(i)<BR> myarray(i)= objOpenfile2.Readline<BR> wend<BR> objOpenFile2.Close<BR> Set objOpenFile2 = Nothing<BR> Set objFSO2 = nothing<BR><BR> pos3=instr(myarray(2),"RA")<BR> strmyarray3=len(myarray(2))<BR> size3 = strmyarray3 - pos3<BR> line3=mid(myarray(2),pos3+5,size3)<BR>

  2. #2
    Join Date
    Dec 1969

    Default Check the UBound of myarray.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts