Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Mid Function

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49851
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Mid Function
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Mid Function - 7/23/2007 4:40:09 PM   
  peachtea

 

Posts: 41
Score: 0
Joined: 7/5/2007
From: Singapore
Status: offline
Hi All

I have this line


      

It is able to read the 1st two characters as wanted. But I would like it to be able to read every line n now just the 1st line in the file
How do i do that?

Sorry i know this sounds like an amateur qn but i couldn't find it via google...
Thanks once again
 
 
Post #: 1
 
 RE: Mid Function - 7/23/2007 6:20:38 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Well, you have two options

1) Read the file into an Array using Split function


      

2) Read each line individually


      

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to peachtea)
 
 
Post #: 2
 
 RE: Mid Function - 7/23/2007 9:05:05 PM   
  peachtea

 

Posts: 41
Score: 0
Joined: 7/5/2007
From: Singapore
Status: offline
hi ginolard

thanks for ur reply!

i need to read all the files in a particular folder in the same way and have modified it to this


      

and I got error on this line    Do Until InputFile.AtEndOfStream

Did i do something wrong?
My error msg says "Object required: ''             Code: 800A01A8"

Pls help~! thanks!

(in reply to ginolard)
 
 
Post #: 3
 
 RE: Mid Function - 7/23/2007 10:04:51 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
The error message says it all.

The Do Loop cannot find an object to do anything with.  You need to define the InputFile object using

Set InputFile=objFSO.OpenTextFile(objFile,1)

However, bear in mind that this will ONLY work for text files.  Your script will causes binary files to attempt to be read as well and that will generate an error.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to peachtea)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Mid Function Page: [1]
Jump to:





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
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts