2016-03-24 64 views
0

我需要援助......我正在尝试创建一个带有链接的文本文件。代码我有..VB.Net无法创建“新行”“字符串”

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”,但是当复制到文本文档,它是: Line0: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”不是一个或另一个。

回答

0

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

0

我想你应该移动到StringBuilder的第一进口进口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 

你刚才应该把它编辑以适合您的需求我不明白你需要的究竟是什么