Computing.Net > Forums > Programming > vb read and write file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

vb read and write file

Reply to Message Icon

Name: gorf
Date: June 1, 2003 at 18:05:37 Pacific
OS: winxp
CPU/Ram: 2600+ / 512mb pc3200
Comment:

anyone know how to read a file in vb
like read file.txt text form file go to text1.text

and write to file



Sponsored Link
Ads by Google

Response Number 1
Name: micah
Date: June 2, 2003 at 16:06:44 Pacific
Reply:

I do.


0

Response Number 2
Name: micah
Date: June 2, 2003 at 20:36:07 Pacific
Reply:

Dim FileData As String
Open "c:\file.txt" For Binary Access Read As #1
FileData = Space(LOF(1))
Get 1, , FileData
Close #1

That'll read.

Open "c:\text1.txt" For Binary Access Write As #1
Put 1, , FileData
Close #1

That'll write...

You can also read and write to the same file at the same time.

Dim FileData As String
Open "c:\blabla.txt" For Binary Access Read Write As #1
FileData = Space(LOF(1))
Get 1, , FileData
Put 1, , "stuff" & FileData
Close #1

Easy enough?


0

Response Number 3
Name: gorf
Date: June 3, 2003 at 11:42:48 Pacific
Reply:

ummmm..... im readin it learn it


0

Response Number 4
Name: gorf
Date: June 3, 2003 at 12:00:12 Pacific
Reply:

hows about in the dame dir as the app?


0

Response Number 5
Name: Chi Happens
Date: June 22, 2003 at 05:46:13 Pacific
Reply:

Well, not certain about the sex of the object but:

App.Path

works for the current path.

you might need to append a "\" before your file name tho.

like FileSpec = App.Path & "\myfile.txt"


0

Related Posts

See More



Response Number 6
Name: Carlos Eugênio
Date: July 17, 2003 at 10:31:15 Pacific
Reply:

I'm doing like you said, but when I execute the following error appears:

Runtime Error: 75
Path/File access error

Please, answer me on my email. Thanks!


0

Response Number 7
Name: Carlos Eugênio
Date: July 17, 2003 at 10:41:56 Pacific
Reply:

In fact, I’d like to read the contents of a binary file, find an specific string in it and finally change this string with another one I want, writing it on the same file, keeping the binary aspect and not damaging the file. As we do using hexdecimal editors.

How can I do it?

Please, answer me on my email.
Thanks.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Inline functions hugging the Processor



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: vb read and write file

Read and Write binary-Serial Port www.computing.net/answers/programming/read-and-write-binaryserial-port-/14491.html

how to read and write the disk www.computing.net/answers/programming/how-to-read-and-write-the-disk-/11804.html

vb binary file readin and writing www.computing.net/answers/programming/vb-binary-file-readin-and-writing/4232.html