[RESOLVED] [2005] Saving Texbox1.Text - TextBox10.Text to file.txt
Hello mates,
Im new in VB programming. I'm using Visual Basic language to programm my test apz. So i have little question.
Actually i can save TextBoxes like that text1text2 ... text10
but I want that TextBox1.Text to TextBox10.Text save to file.txt with one way that the file.txt would be smth like that formating:
text1
text2
text3
...
text10
And then i want to read all data in file.txt and put them back to the TextBoxes same order as they are in file.txt
I will be waiting for helpful replay's
Thanks:wave:
Re: [2005] Saving Texbox1.Text - TextBox10.Text to file.txt
Code to write to file:
Code:
writer as TextWriter =new TextWriter("c:\temp\outputfile.txt");
Dim textbox As TextBox
foreach ctrl As Control in Me.Controls
if typeof(ctrl) is TextBox then
textbox = CType(ctrl, TextBox)
writer.WriteLine(textbox.Text)
end if
next ctrl
writer.Close()
Code to read from file:
Code:
reader as TextReader =new TextReader("c:\temp\outputfile.txt");
Dim textbox As TextBox
foreach ctrl As Control in Me.Controls
if typeof(ctrl) is TextBox then
textbox = CType(ctrl, TextBox)
textbox.Text=reader.ReadLine()
end if
next ctrl
reader.Close()
Re: [2005] Saving Texbox1.Text - TextBox10.Text to file.txt
vb Code:
IO.File.WriteAllLines("file path here", _
New String() {Me.TextBox1.Text, _
Me.TextBox2.Text, _
... , _
Me.TextBox10.Text})
vb Code:
Dim lines As String() = IO.File.ReadAllLines("file path here")
Me.TextBox1.Text = lines(0)
Me.TextBox2.Text = lines(1)
...
Me.TextBox10.Text = lines(9)
Re: [2005] Saving Texbox1.Text - TextBox10.Text to file.txt
Thanks jmcilhinney :wave: :thumb: :thumb: :thumb: