Combo box values from array generated with table value using DataTable.Rows(index)("fieldname")

I cannot get my combo box to populate with an array that is based on a string in a table I use.

dt is the DataTable
index is a string that contains the index number from a DataRow
array_value is the field name that contains the text     {"", "Mr.", "Mrs.", "Dr."}

       Dim arrCriteria1() As String = dt.Rows(index)("array_value")
       cboCriteria1.DataSource = arrCriteria1

Regardless of what I do I continue to get a "specified cast is not valid" error.

I can however see that dt.Rows(index)("array_value") contains an appropriate value using MsgBox.
I also took the '{}' characters out of the array_value string and set up the command as follows:

       Dim arrCriteria1() As String = {dt.Rows(index)("array_value")}

It displayed the whole string..."", "Mr.", "Mrs.", "Dr." cboCriteria1.Text
I'm assuming it has to do with a conversion.  But I am without the knowledge of it.
This is a critical form in my design.  Without this capability I'm dead in the water.

Thanks for any help!

Who is Participating?
Check the Length of your string array. It probably says 1, because the value you are providing is just a string that looks like an array.

To make it into an array use Split like e.g.

    Dim a As String = """test"",""test2"",""test3""" ' example data like you are providing now

    Dim ar() As String = a.Split(","c) ' split the data on the comma

You might want to replace the " with nothing later, but I let that up to your imagination
TSFLLCAuthor Commented:
That worked like a charm!

My arrays in this form contain a limited number of values.

Therefore, I did remove the quotations altogether.  I also included in empty string for the first value so that no values would display in
my newly defined combo box.

Thanks much!
You're welcome!
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.