通过Webclient如何列出?

时间:2017-09-21 22:46:50

标签: string vb.net list download

非常简单我相信自己无法得到它

我正在使用字符串示例“88888<> 88888<> 88888<>”而我想做的就是删除“<>”把它放在一个列表的第二行,然后放在列表的第二行,这样它就会变成

  1. 88888
  2. 88888
  3. 88888

2 个答案:

答案 0 :(得分:0)

此代码使用.IndexOf().SubString()为您完成工作。还有其他更短的方式,实际上还有很多,但我写了这个,这样你就可以知道每一步中发生了什么,并知道确切的解决方案。

    Dim FInalString As String
    Dim String_ As String = "88888<>8888888<>88888<>"
    'now find the position of first <>
    Dim firstsign_ As Integer = String_.IndexOf("<", 0)
    'add string upto that point in the textbox
    FInalString = "1. " & String_.Substring(0, firstsign_)
    'now find the position of second <>
    Dim secondSign_ As Integer = String_.IndexOf("<", firstsign_ + 2) 'here, not 0 because we have to skip the first one
    ' MsgBox(secondSign_)
    'add the string upto that point in the textbox
    FInalString = FInalString & vbCrLf & "2. " & String_.Substring(firstsign_ + 2, secondSign_ - firstsign_ - 2) 'vbCrLf means go to next line now
    'now find the third sign, last 
    Dim lastsign_ As Integer = String_.IndexOf("<", secondSign_ + 2)
    'add to the string 
    FInalString = FInalString & vbCrLf & "3. " & String_.Substring(secondSign_ + 2, lastsign_ - secondSign_ - 2)

    MsgBox(FInalString)

输出:

  
      
  1. 88888
  2.   
  3. 8888888
  4.   
  5. 88888
  6.   

答案 1 :(得分:0)

我不知道这与WebClient有什么关系。但这应该可以根据需要运作。

    Dim str As String = "88888<>88888<>88888<>"
    Dim strarr As String() = str.Split("<>")
    Dim result As String = ""
    For i As Integer = 0 To strarr.Length
        result &= (i + 1) & ". " & strarr(i)
    Next