Welcome !
         

 trying to read TXT file and match all dates inside it BUT always give me error. .pls help

Author Message
rand

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 2/9/2016
  • Status: offline
trying to read TXT file and match all dates inside it BUT always give me error. .pls help Tuesday, February 09, 2016 7:36 AM (permalink)
0
"LIRRR 1M",.412900,02/08/2016 "LIRRR 3M",.222700,02/08/2016 "LIRRR 6M",.333200,02/08/2016 "LIRRR12M",1.1333300,02/08/2016 "FEDFRRRR",.333000,02/08/2016 "CCC 1YR",.550330,02/08/2016 "5YRCMT",1.2503300,02/08/2016 "10YRCMT",1.860000,02/08/2016
 On error resume nex
  tConst ForReading = 1     
 Dim strSearchFor
 Dim MyDate, MyWeekDay 
 MyDate = Date ' Assign a date    
 MyWeekDay = Weekday(MyDate)      
 If MyWeekDay = 2 then      
 strSearchFor =Right("0" & DatePart("m",Date), 2)&"/"&Right("0" & DatePart("d",Date-3), 2)&"/"&DatePart("yyyy",Date)    
  Else      
 strSearchFor =Right("0" & DatePart("m",Date), 2)&"/"&Right("0" & DatePart("d",Date-1), 2)&"/"&DatePart("yyyy",Date) End If     
 Set objFSO = CreateObject("Scripting.FileSystemObject")  
 Set objTextFile = objFSO.OpenTextFile("C:\Users\rand.mahmwd\Desktop\index.txt", ForReading)     
 Do until objTextFile.AtEndOfStream    
  strLine = objTextFile.ReadLine()   
       If InStr(strLine, strSearchFor) <> 0 then   
     Set objFile = objFSO.CreateTextFile("C:\Users\rand.mahmwd\Desktop\pass.txt")   
       objFile.Write "date is  match"& vbCrLf    
         Else          
 Set objFile = objFSO.CreateTextFile("C:\Users\rand.mahmwd\Desktop\error.txt")    
     objFile.Write "date is not match"& vbCrLf    
   End If   
 loop   
 objTextFile.Close    
 
 
 
the problem is always give me error.txt even if all dates is matched  
thanks  


 
 
#1
    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 3 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2017 ASPPlayground.NET Forum Version 3.9