2016-03-24 92 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 

你剛纔應該把它編輯以適合您的需求我不明白你需要的究竟是什麼