read/wright

starcraft

Well-known member
Joined
Jun 29, 2003
Messages
167
Location
Poway CA
How do i have VB.net either wright a file that it can read and edit or create a Excel Spread sheet that it can read and edit?
 
Check out the StreamWriter
Code:
Dim SW As StreamWriter = File.CreateText("C:\test.txt")
SW.WriteLine("Hello There!")
SW.Close
Doing an Excel Spreadsheet requires you to use the Excel libraries and functions.
 
System.IO.StreamWriter is the full name.
You can import System.IO as well.
For removing items from the file, you need to use System.IO.StreamReader to read the file, determine if you want to keep this line, and, if you do, write it with the System.IO.StreamWriter
 
hmmm this IO thing just isnt working for me, though nothing ever does but when i put either
Code:
system.IO.StreamReader
or
Code:
 IO.StreamReader
i get
C:\Documents and Settings\Michael\My Documents\Visual Studio Projects\AutoComplete\Form1.vb(95): StreamReader is a type in IO and cannot be used as an expression.
 
Did you declare a variable for StreamReader or can you not get either StreamReader or StreamWriter to work.
Code:
Imports System.IO
...
Dim SR As StreamReader = File.OpenText("C:\test.txt")
Dim SW As StreamWriter = File.CreateText("C:\test2.txt")
Dim S As String
S = SR.ReadLine()
SW.WriteLine(S)
SR.Close()
SW.Close()
 
when i do that code both the Stringread and wright wont work, they are underlined in blue saying that they are not defined
 
Back
Top