In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to save the data as a VB.NET TXT file", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to save the data as a VB.NET TXT file" this article.
VB.NET TXT file code:
Private Sub Command1_Click () 'write file example Dim strFileName As String' filename Dim lngHandle As Long 'handle Dim strWrite As String' text content to be written strFileName = App.Path & "\ a.txt" 'App.Path & "\ a.txt" relative path''"c:\ w.txt" absolute path lngHandle = FreeFile () 'get handle' what is to be written StrWrite = Text1.Text'or strWrite = "these words will be written to the file." The parameters after For indicate how to open the file. Input is read, Output is overwrite, and Append is appended write. Append is written at the end of the file without deleting other existing files. If you change it to output, delete other files and then write 'print#1,text1.text'. If print is replaced by write, write it into txt and automatically add double quotation marks to Open strFileName For Output As lngHandle'to open the file Print # lngHandle. StrWrite 'write text Close lngHandle' close file End Sub Private Sub Command2_Click () 'read file example Dim strFileName As String' file name Dim lngHandle As Long 'file handle Dim strLine As String' store the contents of each line in the loop strFileName = App.Path & "\ a.txt" 'get the handle to the file lngHandle = FreeFile ()' For Indicates how to open the file Input is a read, Output is an overwrite, Append is an append write Open strFileName For Input As lngHandle 'loop until the end of the file Do While Not EOF (lngHandle)' each read line is stored in the strLine variable Line Input # lngHandle, strLine 'connects what it reads to the strAll variable, because Line Input removes the newline character So here add the full content displayed by strAllstrAll = strAll & strLine & vbCrLf Loop 'MsgBox strAll End Sub Private Sub Command1_Click () Open App.Path & "\ a.txt" For Output As # 1 Print # 1, Text1.Text' here can be either the data itself or the property of the target control Close # 1 'close the open file End Sub' For the parameter after indicating how to open the file, Input is to read Output is an overwrite and Append is an append write
Append is written at the end of each file without deleting other existing files. If replaced by output, delete other files and then write to print#1,text1.text. If print is replaced by write, it will be written into txt and then automatically enclosed in double quotation marks. This is the code for saving data as VB.NET TXT file.
The above is all the contents of the article "how to save data as a VB.NET TXT file". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.