vb.net代码从第二个位置分隔符拆分字符串

时间:2014-09-09 04:46:30

标签: vb.net split

add = address.Split(",")
For count = 0 To add.Length - 1
para = New Paragraph(add(count), FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
para.Alignment = Element.ALIGN_LEFT
document.Add(para)

下一步

上面的代码将新行中的所有字符串拆分。我想在找到第二个位置分隔符时拆分字符串

2 个答案:

答案 0 :(得分:1)

如果我的问题正确,那么你想从第二个位置得到字符串。在这种情况下,您可以启动循环形式1而不是0。

    For count = 1 To add.Length - 1
      'Your piece of code
    Next

答案 1 :(得分:0)

此代码正在根据您的要求进行更改

public Class Form1

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim splitchops() As String
    Dim count As Integer
    splitchops = TextBox1.Text.Split(",")

    For count = 0 To splitchops.Length - 1
      If count = 0 Then
        ListBox1.Items.Add(splitchops(count).ToString + "," + splitchops(count + 1).ToString)
      ElseIf count = 2 Then

        ListBox1.Items.Add(splitchops(count).ToString)
      End If
    Next

  End Sub
End Class