tinomesa Posted July 31, 2003 Posted July 31, 2003 Greetings, I have an application that reads data from a dataset and writes to a text file a formatted version of the data. I have two numeric (double) type fields that I need to write to the file while preserving any spaces to the left of the number (this is requiered by the program that uses the file as input). For example the text is written as "-1000.45" instead of " -1000.45" It needs to be 12 spaces and right justfied. I am reading the data like this..... Public Function WriteTemp(ByVal uid As String) code removed for clarity For i = 0 To _DS.Tables(0).Rows.Count - 1 For innerloop = 0 To 8 line = line + CStr((_DS.Tables(0).Rows(i).Item(innerloop))) Next innerloop = 0 line = line + " " For innerloop = 9 To 28 line = line + CStr((_DS.Tables(0).Rows(i).Item(innerloop))) Next ezwriter.WriteLine(line) line = "" Next ezwriter.Close() End Function Quote
JABE Posted August 1, 2003 Posted August 1, 2003 Perhaps this could get you started: Dim writer As New System.IO.StreamWriter(New FileStream ("c:\numspace.txt", FileMode.Append)) Dim num As System.Double = -12342.35 writer.WriteLine(System.Convert.ToString(num).PadLeft(12)) writer.Close() End Sub Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.