Split Synatx error

Hello Guys, I am getting below error

Can anyone help, where I am getting wrong

2 Likes

Hello @NikhilRPA

What is the data type of the variable text? It should be of type string.

Change that and see whether this works.

You can also try this way

Text.Split(" "c)

2 Likes

Hi,

String.Split method returns string array, so text = text.split(CChar(" ")) is wrong sentence
You need to write like the following.

stringArrayVar = stringVar.Split.split(CChar(" "))
or
text = text.Split.split(CChar(" "))(0)
(text should be String type)

Regards,

3 Likes

Can we see the value that you wanted to split. ? @NikhilRPA

By the way for your reference kindly see the article below.

cheers :smiley:

Happy learning :smiley:

3 Likes

@Lahiru.Fernando Hi, The datatype for the variable text is Array(String)

I am getting same error if I use the syntax you told

1 Like

@pattyricarte I wanted to split the word “City Hyderabad”

1 Like

Hi @NikhilRPA

Use this StringVariable.split(" "c) and pass it to array and you will get the value using index 0 and 1 :smiley:

As i can see to your respond to @Lahiru.Fernando the data type of th string is array.

So no need for you to split it ryt.You just need to use the index in the array of use for each to get the value.

cheers :smiley:

Happy learning :smiley:

3 Likes

@Yoichi- Hey but in the video of tutorial about split, it work’s fine with same syntax i posted

1 Like

@pattyricarte- If you see the above screen shot I posted with error using the same syntax text.split(" "c)

1 Like

Yah i saw it i edit my post.Just use foreach for it and you will get the value or index @NikhilRPA

cheers :smiley:

Happy learning

4 Likes

No I just want to spilt the words by using space as delimeter and send that split values into array variable and display using for each

Text= text.split(" ",c)

3 Likes

But as you mentioned it was an array of string so my perception no need to split it.Because when you use the text.split it will create an array of string.!

you just need to text(0).ToString or text(1).ToString to get the value or you can use Foreach to iterate in the array of string and easily get the value.

cheers :smiley:

Happy learning :smiley:

5 Likes

Got you thanks @pattyricarte

2 Likes

No worries @NikhilRPA

Happy to help here :smiley:

cheers :smiley:

Happy learning :smiley:

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.