Hi all
my code is :

Dim s, w As String
s = "a b c 1"
w = [U]s.Split(" ")[/U]

The error is Value of type '1-dimensional array of string' cannot be converted to 'String'.
Any ideas ?

Recommended Answers

All 2 Replies

Split() method return an array of string.

Dim w() as string = s.Split(" ")

Hi,

Here's an example how to do this.

Public Class SplitTest
    Public Shared Sub Main()
        Dim words As String = "This is a list of words, with: a bit of punctuation" + _
                              vbTab + "and a tab character."
        Dim split As String() = words.Split(New [Char]() {" "c, ","c, "."c, ":"c, CChar(vbTab) })

        For Each s As String In  split
            If s.Trim() <> "" Then
                Console.WriteLine(s)
            End If
        Next s
    End Sub 'Main
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.