Beginners, baidu BBS to ask out text save But if I have 500 textbox, can only write like this? Failed in his own ideas for circulation, Consult the bosses have what simplified method?
Dim PathUserData As String="d: \ 11111. TXT" 'text file is written to Dim t the As System. IO. StreamWriter=New System. IO. StreamWriter (PathUserData, False, System. Text. Encoding. UTF8) T.W riteLine (TextBox1. Text) T.W riteLine (TextBox2. Text) T.W riteLine (TextBox3. Text) T.W riteLine (TextBox4. Text) T.W riteLine (TextBox5. Text) T.W riteLine (TextBox6. Text) T.W riteLine (TextBox7. Text) T.W riteLine (TextBox8. Text) T.W riteLine (TextBox9. Text) T.W riteLine (TextBox10. Text) T.W riteLine (TextBox11. Text) T.W riteLine (TextBox12. Text) T.W riteLine (Label4. Text)
Tc lose ()
Dim As the sr System. IO. StreamReader=New System. IO. StreamReader (" d: \ 11111. TXT ", System. Text. The Encoding. The Default) Dim line As String Line=sr. ReadLine 'text file to read Me. TextBox1. Text=line The line=sr. ReadLine Me. TextBox2. Text=line The line=sr. ReadLine Me. TextBox3. Text=line The line=sr. ReadLine Me. TextBox4. Text=line The line=sr. ReadLine Me. TextBox5. Text=line The line=sr. ReadLine Me. TextBox6. Text=line The line=sr. ReadLine Me. TextBox7. Text=line The line=sr. ReadLine Me. TextBox8. Text=line The line=sr. ReadLine Me. TextBox9. Text=line The line=sr. ReadLine Me. TextBox10. Text=line The line=sr. ReadLine Me. TextBox11. Text=line The line=sr. ReadLine Me. TextBox12. Text=line The line=sr. ReadLine Me. Label4. Text=line The sr. The Close ()
CodePudding user response:
Dim As Integer I For I=1 To 500 Dim (c) As the Control=Me. Controls. Find (" TextBox "& amp; I, False) MessageBox. Show (c (0). The Text) Next