Home > Net >  How do help you, vb.net save to read the text?
How do help you, vb.net save to read the text?

Time:10-05

Because work for self-study vba and then learned vb6, get a little bit of innovation for work
Baidu for a long time all failed hungry
Below is as before with the code template hungry before

CodePudding user response:

You should use the database to realize this,

Then you the following code is the good old way, even write a text file, I feel now don't have to write in this way,

Vb.net is a simple method and direct write a string to a file, the last parameter is covered or additional
My.Com puter. FileSystem. WriteAllText (" name ", "content", False)

.net normal write string to a file as follows, or to write the way as flow, and asynchronous grammar, writing files just far too
Using outputFile As New IO. StreamWriter (" WriteLines. TXT ")
OutputFile. WriteLine (" content ")
End Using


CodePudding user response:

reference 1st floor HZTLTGG response:
you should use the database to achieve this,

Then you the following code is the good old way, even write a text file, I feel now don't have to write in this way,

Vb.net is a simple method and direct write a string to a file, the last parameter is covered or additional
My.Com puter. FileSystem. WriteAllText (" name ", "content", False)

.net normal write string to a file as follows, or to write the way as flow, and asynchronous grammar, writing files just far too
Using outputFile As New IO. StreamWriter (" WriteLines. TXT ")
OutputFile. WriteLine (" content ")
End Using

Well, the key I'm half way becoming a monk, only know some vb6 , I'll try, thanks

CodePudding user response:

https://blog.csdn.net/lsh2216024/article/details/3596973? Utm_medium=distribute. Pc_relevant_bbs_down. None - task - blog - baidujs - 1. Nonecase& Depth_1 - utm_source=distribute. Pc_relevant_bbs_down. None - task - blog - baidujs - 1. Nonecase

There are many online

CodePudding user response:

reference 3/f, 123 handicraft response:
https://blog.csdn.net/lsh2216024/article/details/3596973? Utm_medium=distribute. Pc_relevant_bbs_down. None - task - blog - baidujs - 1. Nonecase& Depth_1 - utm_source=distribute. Pc_relevant_bbs_down. None - task - blog - baidujs - 1. Nonecase

There are many online

Ok, thanks, I have solved, baidu out leave bosses again with new problems

CodePudding user response:

Want to use the method of additional written
System. IO. File. AppendAllText (" d: \ 123. TXT ", text1. Text)

CodePudding user response:

reference 1st floor HZTLTGG response:
you should use the database to achieve this,

Then you the following code is the good old way, even write a text file, I feel now don't have to write in this way,

Vb.net is a simple method and direct write a string to a file, the last parameter is covered or additional
My.Com puter. FileSystem. WriteAllText (" name ", "content", False)

.net normal write string to a file as follows, or to write the way as flow, and asynchronous grammar, writing files just far too
Using outputFile As New IO. StreamWriter (" WriteLines. TXT ")
OutputFile. WriteLine (" content ")
End Using

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 ()
Bosses, is there any way to simplify this code? If I have 500 text can only like this

CodePudding user response:

Dim As Integer I
Dim strTemp as string
For I=1 To 500 '500 according To the actual number of modified here
Dim (c) As the Control=Me. Controls. Find (" TextBox "& amp; I, False)
StrTemp=strTemp & amp; C (0). The Text & amp; VBCRLF
Next
Then save strTemp to a text file

CodePudding user response:

Imports System
Imports System. IO
Imports System. Text. RegularExpressions
'namespace in the code of the top -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Dim n_Rfiles As IO. StreamReader=New IO. StreamReader (" C: \ 1. TXT ") 'definition file operations class object
Dim n_Read As String
Do While n_Rfiles. EndOfStream=False 'judgment whether or not to the end of the file
N_Read=n_Rfiles. ReadLine 'ReadLine method for line by line read

Loop

Dim n_Wfiles As IO. StreamWriter=New IO. StreamWriter (" C: \ 1. TXT ")
Dim Ba As String="ABC"
nullnullnull
  • Related