Splitting a string on comma and printing the results

前端 未结 3 762
我在风中等你
我在风中等你 2021-01-19 11:39

I am using the following code to split a string and retrieve them:

Private Sub Button1_Click(sender As Object, e As EventArgs) 
      Handles Button1.Click
          


        
3条回答
  •  有刺的猬
    2021-01-19 12:01

    You already have each part - just display it:

    For Each part In parts
      MsgBox(part)
    Next
    

    part(0) will return the first item in the character collection that is a string.

    If you want a specific index into the returned string array (as suggested by your comment), just access it directly:

    Dim parts As String() = s.Split(New Char() {","c})
    Dim firstPart As String = parts(0)
    Dim thirdPart As String = parts(2)
    

提交回复
热议问题