How to parse a string in VB.NET

2 Answers

0 votes
Module Module1

    Sub Main()

        Dim s As String = "vb.net c# c c++ java"

        Dim words As String() = s.Split(" ")

        For Each s In words
            Console.WriteLine(s)
        Next s

    End Sub

End Module

' run:
' 
' vb.net
' c#
' c
' c++
' java

 



answered Mar 20, 2017 by avibootz
0 votes
Module Module1

    Sub Main()

        Dim s As String = "vb, c# c,, c++: java."

        Dim sep() As Char = {",", " ", ":", "."}

        Dim words As String() = s.Split(sep)

        For Each s In words
            If (s <> "") Then
                Console.WriteLine(s)
            End If
        Next s

    End Sub

End Module

' run:
' 
' vb
' c#
' c
' c++
' java

 



answered Mar 20, 2017 by avibootz

Related questions

1 answer 119 views
1 answer 208 views
1 answer 193 views
1 answer 173 views
1 answer 89 views
89 views asked Jan 31, 2025 by avibootz
...