How to save small amount of data to text file

G

gordon

Hi

i am using visual studio.net 2003 EA Edition and trying to use vb.net to
write the values of a text box to a text file. I would like to write a csv
file or an excel spreadsheet from the text box.


I have 20 text boxes and would like to write them like this:
1,2,3,4,5,6,7,8,9,10 .... 20

all values will be strings.
Any help appreciated

Thanks
 
C

Cor Ligthert

Gordon,.

Use a string builder,
Someting as
\\\
dim mysb as new stringbuilder
mysb.add(mytextbox1.text)
mysb.add(",")
mysb.add(mytextbox2.text)
'and so on.
dim mystring to write = mysb.tostring
///

I hope this helps,

Cor
 
H

Herfried K. Wagner [MVP]

gordon said:
i am using visual studio.net 2003 EA Edition and trying to use vb.net to
write the values of a text box to a text file. I would like to write a
csv file or an excel spreadsheet from the text box.


I have 20 text boxes and would like to write them like this:
1,2,3,4,5,6,7,8,9,10 .... 20

Take a look at the classes in the 'System.IO' namespace, namely
'StreamWriter'.
 
G

gordon

Thanks Cor

But this doesn't seem to work for me ...

I have:
Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim player1 As String

Dim player2 As String

Dim player3 As String

Dim player4 As String

'this part saves the info for the players

player1 = TextBox1.Text

player2 = TextBox2.Text

player3 = TextBox3.Text

player4 = TextBox4.Text

'continues up to player20

Dim mysb As New Stringbuilder

mysb.add(TextBox1.Text)

mysb.add(",")

mysb.add(TextBox2.Text)

dim mystring to write = mysb.tostring

End Sub



and i get syntax error with this code.






But the syntax
 
H

Herfried K. Wagner [MVP]

gordon said:
Dim mysb As New Stringbuilder

mysb.add(TextBox1.Text)

mysb.add(",")

mysb.add(TextBox2.Text)

dim mystring to write = mysb.tostring

End Sub



and i get syntax error with this code.

Maybe 'Imports System.Text' is missing on top of the file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top