Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: zeth369 on September 29, 2004, 08:44 PM

Title: Read/Write from files
Post by: zeth369 on September 29, 2004, 08:44 PM
.. just what the title says.. im trying to make my very first bot.. and I'm not sure how to read or write from files.. could someone please help.. i need this for my config..
Title: Re: Read/Write from files
Post by: Michael on September 30, 2004, 04:14 PM
To read a file

Open app.path & "/filename.txt" for input as #1
dim text as string
do until eof(1)
input #1, text
'note that adds each line of the file into the bot then you would have to make 'something to add it to a list box or sort it out
'example
'list1.additem text
'or use instr to check for a certian string

to write to a file instead of Open app.path & "/filename.txt" for input as #1 use Open app.path & "/filename.txt" for output as #1
then instead if input #1, text do print #1, text

Hope this helps you.
Title: Re: Read/Write from files
Post by: ctype on October 24, 2004, 07:18 AM
Or, if you'd find it easier (i don't tho) you could make a reference to Microsoft Scripting Runtime and declare a global variable (like FSO) 'as new FileSystemObject' and then - for example - use it to access file / drive info...

Dim FSO as new FileSystemObject
Dim D as Drive

Set D = FSO.GetDrive("C:\")
MsgBox FormatNumber(D.AvailableSpace / 1024, 0) _
& " Kb"

I prefer to use the good old open / close statements from QBasic, unless I want / need specific info (such as date created) about a file.