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
4 1584
I hope this will do the job (see attachment) - Private Sub Command1_Click()
-
Dim ARRAYTEXT() As String
-
Dim ARRAYLINE() As String
-
Dim i As Integer
-
ReDim ARRAYTEXT(0)
-
ReDim ARRAYLINE(0)
-
ARRAYTEXT = Split(Text1.Text, vbNewLine)
-
For i = LBound(ARRAYTEXT) To UBound(ARRAYTEXT) - 1
-
ARRAYLINE = Split(ARRAYTEXT(i), ",")
-
Text2.Text = Text2.Text & ARRAYLINE(0) & ","
-
Text2.Text = Text2.Text & Format(ARRAYLINE(1), "@@@@@@") & ","
-
Text2.Text = Text2.Text & Format(Str(ARRAYLINE(2)), "@@@@@@@@@@") & ","
-
Text2.Text = Text2.Text & Format(Str(ARRAYLINE(3)), "@@@@@@@") & vbNewLine
-
Next
-
End Sub
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?
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Jesper |
last post by:
How can I open a textfile from C# using notepad (or the
user assigned application for this).
|
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...
|
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |