Solved

write 2 columns

Posted on 2009-04-11
5
212 Views
Last Modified: 2013-12-17
I am writing to a txt file from vb.net.

I cant write 2 columns of data and have the 2nd col start at same place.
Col1 is OK but col2 starts at different places depending on how  big col1 ,row  data is.

How do i force this as currently i use tabs but again this doesnt work.


Private Sub write_file()

        w = File.AppendText(filename)

        eqNo += 1

        count += 1

    

        If count > 2 Then '2nd col

            w.WriteLine()
 

            count = 1

        End If
 

       

        w.Write(eqNo & ") " & eq1)

        w.Write(vbTab & vbTab & vbTab & vbTab)
 

  

        End If

        w.Close()
 

    End Sub

Open in new window

0
Comment
Question by:jagguy
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24121633
So  basically what you are after is a fixed length text file. Have you considered padding the string
0
 

Author Comment

by:jagguy
ID: 24121653
the first col has varied length from 10 to 25 chars so how do i pad this the 1st col is always say 30 chars?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24121686
U can use the padRight method
eg

s2 = "Helllo There"

s2 = s2.PadRight(30, Convert.ToChar(" "))

PadRight returns the padded string, it does not update the string you used it on so you got to assign it to a variable. Same variable works (see above)

Syntax is PadRight(length, char)

so you can pad using any character u want

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 24121689
there is also PadLeft if you want to left pad the string
0
 

Author Comment

by:jagguy
ID: 24121690
 strprint = eqNo & ") " & eq1
        strprint = strprint.PadRight(30)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now