文本框文本到列表框项vb.net

编程入门 行业动态 更新时间:2024-10-23 11:31:00
本文介绍了文本框文本到列表框项vb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

好吧,所以我有一个文本框,该文本框从网站获取项目并粘贴到其中,然后列表框添加了这些项目,但是我希望文本框中的每一行都是一个新项目,而不是将其全部添加为一个

Ok so i have a textbox that gets items from a website and pastes in that then the list box adds the items but i want each line in textbox to be a new item instead it just adds it all as one

这是我的代码

' Procedure: Dim Str As System.IO.Stream Dim srRead As System.IO.StreamReader Try ' make a Web request Dim req As System.Net.WebRequest = System.Net.WebRequest.Create("76.31.248.130/videos.txt") Dim resp As System.Net.WebResponse = req.GetResponse Str = resp.GetResponseStream srRead = New System.IO.StreamReader(Str) ' read all the text TextBox2.Text = srRead.ReadToEnd Catch ex As Exception TextBox2.Text = "Unable to download content" Finally ' Close Stream and StreamReader when done srRead.Close() Str.Close() End Try ' Assign string to reference. Dim value1 As String = TextBox2.Text ' Replace word with another word. Dim value2 As String = value1.Replace("<br>", vbNewLine) TextBox2.Text = value2 ListBox1.Items.Add(TextBox2.Text)

推荐答案

您的问题很难理解.我认为答案是将文本框的文本拆分成一个数组,其中每个项目都是一行,然后将它们添加到列表框中.

Your question is very hard to understand. I think the answer is to split the textbox's text into an array where each item is a single line and then add each of these to the listbox.

您可能想要:

ListBox1.Items.AddRange(TextBox2.Text.Split(vbNewLine))

更多推荐

文本框文本到列表框项vb.net

本文发布于:2023-11-03 20:30:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556012.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本框   文本   列表   net   vb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!