473,386 Members | 1,873 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,386 software developers and data experts.

Help with exporting text and formating vb.net tia sal

Greetings all

I'm trying to export text to a file but the format comes out incorrectly
I'm trying to have an array exported to a text file side by side
Example
Name:
John Doe Jane Doe Sally Joe
45 no address 12 no address 78 has address
123-123-4345 123-233-1234 342-342-2342

The problem is that I can't get the arraylist to come out side by side why is this?
see code below

Dim LineValues() As String
Dim sw As New StreamWriter("v:\test.txt")
Dim counter As Integer
Dim c As New ArrayList

If ComboBox1.Visible = True Then
lboElements.Items.Add(name1.Text & address1.Text & number1.Text)
lboElements.Items.Add(name2.Text & address2.Text & number2.Text)
With c
.Add(name1.Text & Chr(10) &address1.Text & number1.text)
.Add(name2.Text & Chr(10) & address2.Text & number2.text)
End With
For counter = 0 To c.Count() - 1
LineValues = CType(c(counter), String())
MessageBox.Show(LineValues(0))
'Call sw.WriteLine(text1(0) & " - " & text1(1))
Next
sw.Close()
MessageBox.Show("saved")
Nov 21 '05 #1
1 1010
Sal,

Why you use the arraylist in this.
It has no function.

However lets assume that it is a sample to show the problem than the only
thing you have to change is when I see all things right that
LineValues = CType(c(counter), String())
MessageBox.Show(LineValues(0))
'Call sw.WriteLine(text1(0) & " - " & text1(1)) \\\
sw.WriteLine(c(counter).ToString)
///
And why you are using the With clause, you type now 13 characters (including
the spaces) where you need without it only 2. In my opinion does it not make
your program more readable.

I hope this helps?

Cor
What you want is in my opinion not more than this. Dim LineValues() As String
Dim sw As New StreamWriter("v:\test.txt")
Dim counter As Integer
Dim c As New ArrayList

If ComboBox1.Visible = True Then
lboElements.Items.Add(name1.Text & address1.Text &
number1.Text)
lboElements.Items.Add(name2.Text & address2.Text &
number2.Text)
With c
.Add(name1.Text & Chr(10) &address1.Text &
number1.text)
.Add(name2.Text & Chr(10) & address2.Text &
number2.text)
End With
For counter = 0 To c.Count() - 1
LineValues = CType(c(counter), String())
MessageBox.Show(LineValues(0))
'Call sw.WriteLine(text1(0) & " - " & text1(1))
Next
sw.Close()
MessageBox.Show("saved")

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
2
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
5
by: mik18 | last post by:
I'm having trouble with exporting reports to Word in the rtf format and I'm hoping someone has a solution. The reports are losing their formats. Not all the formating is lost but some is and of...
4
by: djc | last post by:
Is there a property or method of the textbox web server control that I can use to format the text in it a certian way. For example I am displaying a date value from a database in a text box. It...
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
24
by: =?Utf-8?B?RHVja3dvbg==?= | last post by:
Hello, My code is suppose to write to an existing file. But after my C# code appends the file, the previous text loses all the endline characters, becoming one long line. How can I retain the...
0
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
hi, I trying to export data display on a gridview that supports any language (like chinese, japanese, thai, french) shown here is chinese only. There is no problem exporting english language...
1
by: pqsoftware | last post by:
Hi, I have the following code to export to a new Excel spreadsheet. What I need to do is format the cells. How can I change the font, font size and colour and most importantly the cells background...
1
by: Marty Klunk | last post by:
I have an Access97 data base where we are exporting records out to a text file that is then sent to a customer via EDI transmission. The problem I am having is that during the export process access...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.