|
-
Apr 12th, 2008, 05:51 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Text File Columns
Ive been trying to use the "ControlChars.Tab" to sort the strings into columns with code from this forum.
Code:
Public Sub save()
'http://www.vbforums.com/showthread.php?t=366421&highlight=listview+textfile
Try
Dim sw As New IO.StreamWriter("C:\StickFrameExpress\Jobs\" & Me.lblJobNumber.Text & ".txt", True)
'header
sw.WriteLine("Component Name, Material Type, Length, Quanitiy, Units, NOTE:")
Dim i As Int16
With Me.ListView1
For i = 0 To CShort(.Items.Count - 1)
If .Items(i).Text <> "" Then
sw.WriteLine(.Items(i).Text & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(1).Text & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(2).Text & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(3).Text & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(4).Text & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(5).Text)
End If
Next
End With
sw.Close()
Me.ListView1.Clear()
Catch ex As Exception
End Try
End Sub
I tried using "ControlChars.Tab" multibly times but as the individual string change in size the column do not line up.

Should i been working with "ControlChars.Tab" for this or something else?
cheers
toe
-
Apr 12th, 2008, 05:53 PM
#2
Re: Text File Columns
Change the font to a mono spaced one, Lucida or Courier come to mind.
You could also try making all of the items the same length.
Code:
sw.WriteLine(.Items(i).Text.PadRight(10, " "c) & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(1).Text.PadRight(10, " "c) & _
ControlChars.Tab & _
ControlChars.Tab & .Items(i).SubItems(2).Text.PadRight(10, " "c)
Last edited by dbasnett; Apr 12th, 2008 at 06:14 PM.
-
Apr 12th, 2008, 06:35 PM
#3
Thread Starter
Frenzied Member
-
Apr 12th, 2008, 06:50 PM
#4
Re: [RESOLVED] Text File Columns
Finally I did some good today. You are welcome!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|