Output help


Mar 3, 2005
Programming Experience
i am currently tryin to output a timestamp and 'highly' to a file but wat happens is that i only get 1 timestamp in the file n thats it!!

only one time vale n no highly
i need a list of everytime a check box is click the time and a string

Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
'output panel2 results to file with a time stamp

Dim oFile As System.IO.File

Dim oWrite As System.IO.StreamWriter

Dim oRead As System.IO.StreamReader

oWrite = oFile.CreateText("C:\reslts.txt")

oWrite.WriteLine("highlY", TimeString)


"> is ther ne code which stops the input from the keyboard?


Active member
Aug 21, 2004
Programming Experience
As you are probably aware, the writeLine method of the StreadWriter class is highly overloaded, meaning that you can have different combination of arguments to do different things. In other words, what it does depends on the NATURE of the arguments.

It may not be obvious from the example, but your WriteLine method is using the syntax of WriteLine(formatString, object), meaning that the object TimeString is written using the string "highlY" as the format string. Thus you would not see the string as output.

To do what you'd like to do, simply execute the method two times, once for the string, and one for the TimeString object.

To solve the problem of having only ONE line in the file:
It also appears that while it is good practice to open and close the file inside of the method, you'd have to open it in append mode so that the previous content will not be lost. Alternatively you open the file outside of the method, thus leaving it open, and not forgetting to close it at the end.

Happy programming.
Top Bottom