Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in RPA by (12.7k points)

I'm working on some code on UiPath, trying to split this string "2700/30" so that I get 2700 and 30 separated.

Tried this "2700/30 “.split(”/"c)(0) but doesn't work, i get my data from excel file, before storing this data into variables i use .toString

PS: Error, says that it can't convert from string to char

myvarA = row.Item(0).ToString

ps : row.Item(0).ToString contains "2700/30"

I need to get this :

myvarA = row.Item(0).ToString myvarB = row.Item(0).ToString

as myvarA = 2700 and myvarB = 30

1 Answer

0 votes
by (29.5k points)

Since you have mentioned var row and excel I am assuming you working with row Datatable and loop. Now you need to understand what your functions return to you so:

  • row(0).ToString gives you the data of the first column of said DataTable as a String. Adjust that 0 to whatever column number you need.

  • The String. split method returns an array of strings, so you can directly ask for the index you need in the same way.

now you can try using these assigns based on the info above:

myvarA = row(0).ToString.Split("/"c)(0)

myvarB = row(0).ToString.Split("/"c)(1)

Related questions

0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Browse Categories

...