saving opening multiple file error
I have written the following code to save the text from multiple textboxes into a single txt file:
Dim sfdAsNew SaveFileDialog
Dim strAsString =""
'add the types you would like belowsfd.Filter =
"Budget Files (*.bgt)|*.txt|All files (*.*)|*.*"sfd.Title =
"Title"'show dialogsfd.ShowDialog()
'use the code below for your next actionIf sfd.ShowDialog() = Windows.Forms.DialogResult.OKThenForEach txtAs ControlInMe.ControlsIfTypeOf (txt)Is TextBoxThenstr += txt.Text.Trim() + vbTab
EndIfNextMy.Computer.FileSystem.WriteAllText(sfd.FileName, str,False) EndIfAfter this, I wrote the following code to open the txt file with all the information from the text boxes, so that all information would return to its corresponding text box (after the text boxes were cleared). All the '.text' items below are the text items:
Dim ofdAsNew OpenFileDialogDim str()AsString'add the types you would like belowofd.Filter =
"Budget Files (*.bgt)|*.txt|All files (*.*)|*.*"ofd.Title =
"Title"'show dialogofd.ShowDialog()
'use the code below for your next actionIf ofd.ShowDialog() = Windows.Forms.DialogResult.OKThenstr =
My.Computer.FileSystem.ReadAllText(ofd.FileName).Split(vbTab)ex1.Text = str(0)
ex2.Text = str(1)
ex3.Text = str(3)
ex4.Text = str(4)
ex5.Text = str(5)
ex6.Text = str(6)
dex1.Text = str(7)
dex2.Text = str(8)
dex3.Text = str(9)
dex4.Text = str(10)
dex5.Text = str(11)
dex6.Text = str(12)
ei1.Text = str(13)
ei2.Text = str(14)
ei3.Text = str(15)
ei4.Text = str(16)
ei5.Text = str(17)
ei6.Text = str(18)
dext1.Text = str(19)
dext2.Text = str(20)
dext3.Text = str(21)
dext4.Text = str(22)
dext5.Text = str(23)
dext6.Text = str(24)
in1.Text = str(25)
in2.Text = str(26)
in3.Text = str(27)
in4.Text = str(28)
in4.Text = str(29)
in5.Text = str(30)
in6.Text = str(31)
din1.Text = str(32)
din2.Text = str(33)
din3.Text = str(34)
din4.Text = str(35)
din5.Text = str(36)
din6.Text = str(37)
ni1.Text = str(38)
ni2.Text = str(39)
ni3.Text = str(40)
ni4.Text = str(41)
ni5.Text = str(42)
ni6.Text = str(43)
dint1.Text = str(44)
dint2.Text = str(45)
dint3.Text = str(46)
dint4.Text = str(47)
dint5.Text = str(48)
dint6.Text = str(49)
dextotal.Text = str(50)
surplust.Text = str(51)
dintotal.Text = str(52)
deficitt.Text = str(53)
EndIfWhen I debug this programme, the all the texts from the textboxes which I saved into a single text file doesn't appear when the corresponding txt file is opened on notepad. I addition, when I try an open this txt file, the following error pops up on the lineex2.Text = str(1)saying 'Index was outside the bounds of the array'. even if I delete this line, the same error appears on the next line down. Why does this all happen? What should I do to fix this?

