【问题标题】:VB.Net Cant create "new line" "string"VB.Net 无法创建“新行”“字符串”
【发布时间】:2016-03-24 06:14:24
【问题描述】:

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

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”不是一个或另一个。

【问题讨论】:

    标签: vb.net string join newline


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      我认为你应该先迁移到 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
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-03-13
        • 1970-01-01
        • 1970-01-01
        • 2012-11-27
        • 2014-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多