Problems splitting a string using non breaking space as a token

I am trying to split a string that is made up of three substrings
seperated by non-breaking spaces.  In fact the string was
created from the attached code snippet i.e. from the concatenation of three database fields
and replacing all spaces with non-breaking spaces.

On the firing of a certain event I am attempting to break up the string
into its substrings using the following code:

Dim values() As String = Split(EMPLIST.SelectedValue, Chr(160), 3)

The first substring (values(0)) comes out correct but the second is invariably an empty string and the third is a concatenation of the last two substrings that I intended to separate.

Anybody sees why I am not getting my three substrings?
SELECT Replace(LEFT(RTRIM(FIRST_NAME) + '                  ', 10) + LEFT(RTRIM(LAST_NAME) + '                    ', 10) + CAST(SSN AS char(10)), ' ', Char(160)) AS column1 FROM EMPLOYEE where DISTRICT = '" + Request.QueryString("district")

Open in new window

sib_userAsked:
Who is Participating?
 
sib_userAuthor Commented:
This works:
Dim values() As String = EMPLIST.SelectedValue.Split(Convert.ToString(Chr(160)).ToCharArray, StringSplitOptions.RemoveEmptyEntries)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.