In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "how to use VB to save list box content as a text file", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use VB to save list box content as a text file"!
Sometimes we need to save the contents of the list box, such as when making a list of playback files for the player. The solution can be like this: use the text box to save all the items in the list box. Here is an example to illustrate the implementation method (to try this example, add several controls by source, where the Multiline property of the TextBox control is set to True and the ScrollBars property is set to 2):
Private Sub Form_Load ()
List1.Clear 'clear the list box
Text1 = "" 'clear the text box
End Sub
'get the screen font name and add it to the list box (to make the list box have content)
Private Sub cmdFindFonts_Click ()
Dim fnt As Integer
For fnt = 0 To Screen.FontCount-1
List1.AddItem Screen.Fonts (fnt)
Next fnt
End Sub
'add all Item of the list box to the text box
Private Sub List1_Click ()
For Index = 0 To List1.ListCount-1
Text1.Text = Text1.Text & List1.List (Index) & vbCrLf
The function of vbrLf is to change lines.
Next Index
End Sub
'Save
Private Sub cmdSave_Click
CommonDialog1.Filter = "text document (* .txt) | * .txt | all files (*. *) | *. *"
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowSave
F = CommonDialog1.FileName
Open F For Output As # 1
Print # 1, Text1.Text
Close # 1
End Sub
In this way, all items in the list box can be saved.
If you save only part of the list box, you can add the following code to the Click event of List1:
Dim i As Integer
I = I + List1.ListIndex
Text1.Text = Text1.Text + List1.List (Index + I) + vbCrLf
This example is debugged in PWin98 and VB6.0 environment.
Thank you for your reading, the above is the content of "how to use VB to save the contents of the list box as a text file", after the study of this article, I believe you have a deeper understanding of how to use VB to save the contents of the list box as a text file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.