VB.Net Cant创建"新线" "串"

时间:2016-03-24 06:14:25

标签: vb.net string join newline

我需要帮助...我正在尝试创建一个带有链接的文本文件。我有的代码..

dim domain as string = "http://www.mywebsite/"
dim name as string = "username"
Dim link As String = New String("domain" & "name")
                TextBox1.AppendText(link & Environment.NewLine)
Msgbox(textBox1.lines(0))

问题是MsgBox只显示为" http://www.mywebsite/"。文本框确实显示" http://www.mywebsite/username"但是当复制到文本文档时,它是:  第0行:http://www.mywebsite/  线路1:用户名  任何想法...尝试使用 Dim link As String = String.Join(domain & name)但这不起作用 Dim link As String = new String.Join(domain & name) 我需要 Msgbox(textBox1.lines(0))显示" http://www.mywebsite/username"不是一个或另一个。

2 个答案:

答案 0 :(得分:0)

很快得到了一条消息说要使用。 Dim link As String = String.Concat(domain & name)

答案 1 :(得分:0)

我认为您应该首先导入StringBuilder Imports System.Text

'create a string with multiple lines
Dim a As New StringBuilder
a.AppendLine("hi")
a.AppendLine("there")
a.AppendLine("this")
a.AppendLine("is")
a.AppendLine("a")
a.AppendLine("test")

'read will makes read line by line
Dim read As String() = a.ToString.Split(vbNewLine)
'count has number of lines
Dim count As Integer = a.ToString().Split(vbNewLine).Length - 1

'lines will be added to combobox one by one
For i As Integer = 0 To count - 1
    ComboBox1.Items.Add(read(i))
Next

你应该编辑它以满足你的需要我不明白你需要什么