Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Reading a txt-file with VBScript

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Reading a txt-file with VBScript
  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 >>
 Reading a txt-file with VBScript - 10/21/2004 8:58:18 PM   
  blackmoon

 

Posts: 5
Score: 0
Joined: 10/21/2004
From: Belgium
Status: offline
Hello

Is it possible in one way or another to open a txt-file with vbscript, read the data in it and store it in variables?

It may sound as a "dumb" question ... but i'm new to vbscript.

Can anyone help me with this?

greetz Blackmoon

PS: if you know where I can find good tutorials / courses on VBScript, they are most welcome
 
 
Post #: 1
 
 Re: Reading a txt-file with VBScript - 10/21/2004 9:49:26 PM   
  nicksvbs

 

Posts: 26
Score: 0
Joined: 6/28/2004
From:
Status: offline
Two ways to do that: An array and with a dictionary object. Both of the following scripts open and display the lines of c:\boot.ini. As for information on scripting try this http://www.microsoft.com/resources/documentation/windows/2000/server/scriptguide/en-us/sas_vbs_dcot.mspx. It's very good. That's where I learned myself. Good luck learning.

The array:

      


The dictionary object

      

(in reply to blackmoon)
 
 
Post #: 2
 
 Re: Reading a txt-file with VBScript - 10/21/2004 10:18:06 PM   
  blackmoon

 

Posts: 5
Score: 0
Joined: 10/21/2004
From: Belgium
Status: offline
Ok ... thx man :-)

Now i got another question ... is it possible to split a string?

When i read the txt-file I get the following:

DRAWINGS|ISOS|ISO-WN119-0002

but now I would like to split this so that I get 3 different variables:
var1: DRAWINGS
var2: ISOS
var3: ISO-WN119-0002

I know how I can do this in PHP, but I have no clue of how to do it in VBScript

any suggestions?

greetz Blackmoon

(in reply to blackmoon)
 
 
Post #: 3
 
 Re: Reading a txt-file with VBScript - 10/21/2004 11:49:01 PM   
  mbouchard


Posts: 1804
Score: 12
Joined: 5/15/2003
From: USA
Status: online
A couple good sources are the Windows Script help file found here http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en and The TechNet script center found here http://www.microsoft.com/technet/scriptcenter/default.mspx
Example taken from documentation:

quote:
To split a line, use split
MyString = "DRAWINGS|ISOS|ISO-WN119-0002"
MyArray = Split(MyString, "|", -1, 1)
Msgbox MyArray(0)
Msgbox MyArray(1)
Msgbox MyArray(2)

Mike

(in reply to blackmoon)
 
 
Post #: 4
 
 Re: Reading a txt-file with VBScript - 10/21/2004 11:58:25 PM   
  blackmoon

 

Posts: 5
Score: 0
Joined: 10/21/2004
From: Belgium
Status: offline
woot woot

thx, it works just great ... just the way I wanted it

thx again

greetz Blackmoon

(in reply to blackmoon)
 
 
Post #: 5
 
 
 
  

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 >> Reading a txt-file with VBScript 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