Solved

Write data from SQL to CSV file - position

Posted on 2016-08-25
1
52 Views
Last Modified: 2016-08-31
I am trying to create a sub to write fixed lenght to cvs file. Could you help? Max lenght per line is 500.

    Public Sub ExportOrderData()
        Using MyFile1 As New StreamWriter("C:\Temp\MyFile.csv")
         
           position 10 - 15 = write Order #
           position 17 - 25 = write Description
           position 30 - 100 = write Address  

           max size per line is 150


        End Using
    End Sub
0
Comment
Question by:jagr12
1 Comment
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 41771106
Hi  jagr12;

You can use the String.Format Method which will allow you to give field a width value for each specific line position, spaces between columns, how to justify the data in the field and many other options, Have a look at the Microsoft documentation String.Format Method.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

15 Experts available now in Live!

Get 1:1 Help Now