|
-
Nov 2nd, 2005, 03:56 PM
#1
Thread Starter
Lively Member
[RESOLVED] reading and writing to a text file
Can any one help I want to save variable values to a comma seperated txt file but I do not know how to use the file system. I tried using a code sample one of you gave me be it came up withso many error messages I gave up. It would not recognize this for example
Dim sr As stream ' the word stream
' Open the file to read.
sr = File.OpenText("c:\MyFile.txt") ' the word File
And so-on it goes
-
Nov 2nd, 2005, 03:59 PM
#2
Re: reading and writing to a text file
You may use the StreamWriter instead
VB Code:
Dim sr As New IO.StreamWriter("c:\MyFile.txt")
sr.WriteLine(Var1 & ";" Var2 &";" ...)
sr.Close()
-
Nov 2nd, 2005, 04:49 PM
#3
Thread Starter
Lively Member
Re: reading and writing to a text file
Thanks it works why do they make it s complicated it is one of the most used task there are yet try going to the help system there are no clear examples or anything I am begining to think it would be advantagous to get a good book that explains the simple tasks as well as the more complicated one Do you happen to know one (It must be reasonably priced I'm on a budget.
-
Nov 2nd, 2005, 05:02 PM
#4
Re: reading and writing to a text file
 Originally Posted by white_grass
Thanks it works why do they make it s complicated it is one of the most used task there are yet try going to the help system there are no clear examples or anything I am begining to think it would be advantagous to get a good book that explains the simple tasks as well as the more complicated one Do you happen to know one (It must be reasonably priced I'm on a budget.
What version are you using? I don't think it's any more complicated than it needs to be.. It's very fast, also. But regarding your help file question,
http://support.microsoft.com/default...b;en-us;315828
This is word for word what's in the VS 2003 help file (Only reading and writing are separated in the help files, whereas they are one article on MSDN) if I search for "read and write to a text file", or "read from a text file" or "write to a text file" - It's the very first displayed item in the MSDN Search, also.
MSDN is your friend. Well, actually it's a cold, boring server, but it's really helpful if you put it to use.
Bill
-
Nov 2nd, 2005, 05:50 PM
#5
Thread Starter
Lively Member
Re: reading and writing to a text file
that was a very useful tip I will remeber that. The problem I am haveing is that I am self taught and can manipulate VB access to do what I want but this is the first time I have used vb as a stand alone program. I'm slowly getting used to i though. anyway thanks for your helpyet again Im sure you will be hearing from me again sometime
Jem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|