由vb.net拆分字符串

时间:2012-07-18 12:56:37

标签: vb.net

我有一个像这样的html地址行:

Addressline1<br>Addressline2<br>...

如何将它们拆分成数组?

我使用过此代码,但只返回一些字符

                    Dim addressLine As String() = "Address1<br>Address2<br>".Split(New String() {"<br>"}, StringSplitOptions.RemoveEmptyEntries)

                    For index As Integer = 0 To addressLine.Count - 1
                        Dim address As String = "Address" + (index + 1).ToString()
                        Console.WriteLine(address(index))
                    Next

2 个答案:

答案 0 :(得分:3)

你的分裂是有效的,但你的循环毫无意义(不确定你试图用它做什么)。如果你解决了这个问题,它将输出正确的值:

For index As Integer = 0 To addressLine.Count - 1
    Console.WriteLine(addressLine(index))
Next

答案 1 :(得分:1)

Dim Address As String() = addressLine.Split("<br>")