473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

I have a program that prints a text file from notepad at the press of a button

the resulting printout looks like this
1,blue,12345678,54
2,red,00001234,6
3,blue,12345678,63
4,blue,12345678,65
5,red,00001234,17

Is there any way to format it into columns and then print it so it looks like this
1,-----blue,-----12345678,-----54
2,-----red, -----00001234,-----6
3,-----blue,-----12345678,-----63
4,-----blue,-----12345678,-----65
5,-----red, -----00001234,-----17

(ignore the hyphens as they are only there to provide a layout as the page here removes extra spaces)

the text file is generated by an old dos based program run from an exe file called from within VB and as such would be difficult to modify I fear

Many thanks for any suggestions

regards Rob
Jul 19 '10 #1
4 1584
Guido Geurs
767 Expert 512MB
I hope this will do the job (see attachment)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim ARRAYTEXT() As String
  3. Dim ARRAYLINE() As String
  4. Dim i As Integer
  5.    ReDim ARRAYTEXT(0)
  6.    ReDim ARRAYLINE(0)
  7.    ARRAYTEXT = Split(Text1.Text, vbNewLine)
  8.    For i = LBound(ARRAYTEXT) To UBound(ARRAYTEXT) - 1
  9.       ARRAYLINE = Split(ARRAYTEXT(i), ",")
  10.       Text2.Text = Text2.Text & ARRAYLINE(0) & ","
  11.       Text2.Text = Text2.Text & Format(ARRAYLINE(1), "@@@@@@") & ","
  12.       Text2.Text = Text2.Text & Format(Str(ARRAYLINE(2)), "@@@@@@@@@@") & ","
  13.       Text2.Text = Text2.Text & Format(Str(ARRAYLINE(3)), "@@@@@@@") & vbNewLine
  14.    Next
  15. End Sub
Jul 19 '10 #2
My apologies for not replying sooner but I hadn't realised there was a reply to my query before the project was pushed 'to the back burner' by other works
I have had a look at the little program you did but am puzzled as to where the original text comes from, can I insert it from a file?
Aug 9 '10 #3
Guido Geurs
767 Expert 512MB
Sorry for this misunderstanding but in my first answer I had only attached an example with the code how to format the data.
The data was fix in the Textbox1.

Now that I know that Your data is in a file, I have modified the code so You can read the data from a file and write it back to the disk.
Aug 10 '10 #4
Thats absolutely brilliant, I will be able to add that to the bit I have already got and with a little bit of 'tweaking' almost make it 'idiot proof'
You have certainly used some 'hi-tech' expressions that I have never come across before, so I can't thank you enough
Aug 11 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dave B | last post by:
Does anyone know of a program that will read a text file and fill in a web form with the contents of that file? We need to get about 3000 records (5 fields to each record) into a database owned by...
4
by: Jesper | last post by:
How can I open a textfile from C# using notepad (or the user assigned application for this).
3
by: RN Das | last post by:
Hi expert, I have a small web application in C# and ASP.Net and I want to open a file in notepad when clicked on a linked button. Here is hander code when clicked on the link button. It can open...
3
by: I_AM_DON_AND_YOU? | last post by:
In my program I am using the notepad file to read/write data. I don't want that someone should be able to delete/change the contents of that file by opening that file in Notepad or other editor. ...
7
by: Drew Berkemeyer | last post by:
Hello, I'm using the following code to read a text file in VB.NET. Dim sr As StreamReader = File.OpenText(strFilePath) Dim input As String = sr.ReadLine() While Not input Is Nothing...
3
by: Jennifer | last post by:
On an ASP page I've got some code that is supposed to "export" data in a grid to an Excel file. What I'm doing is writing all the data to a text file, separating the fields by commas. Then I'll...
4
by: Daniel Kaseman | last post by:
I want to make a program that has 3 textboxes for inputting: Name, ID, Amount, and then when I click "Add Item" button, it adds it to a text file, and shows up on the list box. When I close and...
2
by: continium | last post by:
I have been learning python during the past weeks and I have been able to program some interesting things. Python is my first and only programing language from which I wish to enter the programing...
4
by: bmruze | last post by:
Hello, I'm pretty new at trying to do things in visual basic and I've been following some steps to do a few things like writing to a .txt file and reading from that same .txt file. Link for writing...
17
by: mse07 | last post by:
hi for all i want to search about specified statement in text file via command button if i click button and the program find this statement it show message box for example : the name of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.