Valhalla Legends Forums Archive | Visual Basic Programming | Read/Write from files

AuthorMessageTime
zeth369
.. 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..
September 30, 2004, 1:44 AM
-MichaeL-
To read a file
[code]
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
[/code]
to write to a file instead of [code] Open app.path & "/filename.txt" for input as #1 use Open app.path & "/filename.txt" for output as #1[/code]
then instead if [code] input #1, text do print #1, text [/code]

Hope this helps you.
September 30, 2004, 9:14 PM
ctype
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.
October 24, 2004, 12:18 PM

Search