View Single Post
  #1 (permalink)  
Old December 27th, 2011, 06:45 PM
Gary108 Gary108 is offline
Authorized User
Points: 193, Level: 3
Points: 193, Level: 3 Points: 193, Level: 3 Points: 193, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Default Writing to Text File

Dear Rod,

Thank you for all of the help that you have given me so far. I really appreciate it. I do have another question. I am still working on another aspect of the application that you helped me with before. The application 1) breaks down a Bitmap image into 90 lines of 64 10x10 pixel images, 2) analysis the colors to determine how many pixels are black and how many are white, 3) depending on the result, it will place either a "1" or a "0" in each of 64 text boxes which represents a series of tiny pictures that make up the first row of the original Bitmap image. I can also successfully write the contents of a set of 64 text boxes to a single line of a Text File.

My difficulty starts after I write the first line to the Text File. What I need is for each successive line of text to be written as another line of the Text File so that we would end up with 90 lines of a 64 digit number. What is actually happening is that each successive line writes over the previous line so I end up with a Text File with only one line of text representing the last line of the image. I have used "objFile.WriteLine()" in my code to add a carriage return, but it is being ignored. My code for writing to a text file is as follows:



Dim objFile As New System.IO.StreamWriter("C:\NewText.txt")
objFile.Write(strTextBox1)
objFile.Write(strTextBox2)
objFile.Write(strTextBox3)
objFile.Write(strTextBox4)
objFile.Write(strTextBox5)
objFile.Write(strTextBox6)
objFile.Write(strTextBox7)
objFile.Write(strTextBox8)
objFile.Write(strTextBox9)
objFile.Write(strTextBox10)
objFile.Write(strTextBox11)
objFile.Write(strTextBox12)
objFile.Write(strTextBox13)
objFile.Write(strTextBox14)
objFile.Write(strTextBox15)
objFile.Write(strTextBox16)
objFile.Write(strTextBox17)
objFile.Write(strTextBox18)
objFile.Write(strTextBox19)
objFile.Write(strTextBox20)
objFile.Write(strTextBox21)
objFile.Write(strTextBox22)
objFile.Write(strTextBox23)
objFile.Write(strTextBox24)
objFile.Write(strTextBox25)
objFile.Write(strTextBox26)
objFile.Write(strTextBox27)
objFile.Write(strTextBox28)
objFile.Write(strTextBox29)
objFile.Write(strTextBox30)
objFile.Write(strTextBox31)
objFile.Write(strTextBox32)
objFile.Write(strTextBox33)
objFile.Write(strTextBox34)
objFile.Write(strTextBox35)
objFile.Write(strTextBox36)
objFile.Write(strTextBox37)
objFile.Write(strTextBox38)
objFile.Write(strTextBox39)
objFile.Write(strTextBox40)
objFile.Write(strTextBox41)
objFile.Write(strTextBox42)
objFile.Write(strTextBox43)
objFile.Write(strTextBox44)
objFile.Write(strTextBox45)
objFile.Write(strTextBox46)
objFile.Write(strTextBox47)
objFile.Write(strTextBox48)
objFile.Write(strTextBox49)
objFile.Write(strTextBox50)
objFile.Write(strTextBox51)
objFile.Write(strTextBox52)
objFile.Write(strTextBox53)
objFile.Write(strTextBox54)
objFile.Write(strTextBox55)
objFile.Write(strTextBox56)
objFile.Write(strTextBox57)
objFile.Write(strTextBox58)
objFile.Write(strTextBox59)
objFile.Write(strTextBox60)
objFile.Write(strTextBox61)
objFile.Write(strTextBox62)
objFile.Write(strTextBox63)
objFile.Write(strTextBox64)
objFile.WriteLine()
objFile.Close()



In my application, the whole process is repeated 90 times using a Timer Event. My code there is:



Private Sub tmrProcesser_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrProcesser.Tick

Static CounterVariable As Integer
CounterVariable = CounterVariable + 1
txtCounterVariable.text = CounterVariable


Process()
CountPixels()
CreateTextFile()

If CounterVariable = 90 Then
tmrProcesser.Enabled = False
End If

End Sub




I've tried to make my inquiry as clear as possible without adding unnecessary code, but if it would help I can add everything. I look forward to your reply. Thanks again for all of your help.


Gary
Reply With Quote