I'm just at the start of learning VB.Net using VB 2008 Express. I'm trying to understand things as I go along but have come across something that I can't grasp.
There are two examples that I am trying to learn at the moment: one for Write and one for WriteLine. But when I check the contents to the text file with the Write example I always get the text preceded by System.Windows.Forms.TextBox, Text: but I just get the text that I'm expecting with the WriteLine example. I just don't understand why. Please help me to understand.
Write Example
Dim
FILE_NAME As String = "C:\test.txt"
If System.IO.File.Exists(FILE_NAME) = True ThenDim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write(TextBox1)
objWriter.Close()
MsgBox("Text written to file")
ElseMsgBox("File Does Not Exist")
End If
WriteLine Example
Dim
FILE_NAME As String = "C:\test.txt"
Dim i As Integer
Dim aryText(4) As String
aryText(0) =
"Mary WriteLine"
aryText(1) =
"Had"
aryText(2) =
"A"
aryText(3) =
"Little"
aryText(4) =
"One"Dim objWriter As New System.IO.StreamWriter(FILE_NAME)For i = 0 To 4
objWriter.WriteLine(aryText(i))
Next
objWriter.Close()
Enter your message below
Sign in or Join us (it's free).