Link to home
Start Free TrialLog in
Avatar of NeGueSa
NeGueSaFlag for United States of America

asked on

How do I convert a string to an array from Visual studio 2005 "VB codebehind"

How do I convert a string to an array from Visual studio 2005 "VB codebehind"
Let say I have a label which contain following string :
"'ABC', 'DEF', 'GHI', 'JKL', 'MNO'"
I nee to convert this as an Array, can anybody helps?
Avatar of divinewind80
divinewind80

You should be able to set it as a single dimesion array as follows:

Dim string1(5) as string

This allows you to do the following, and store it as an array:
string(1) = "ABC"
string(2) = "DEF"

Is this what you are looking for?
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or try this?

        Dim i As Integer
        Dim str As String

        str = "'ABC', 'DEF', 'GHI', 'JKL', 'MNO'"
        Dim aryStr() = str.Split(",")

        For i = 0 To aryStr.Length - 1
            Console.WriteLine((aryStr(i).ToString().Trim()))
        Next


hongjun
Or to throw yet another variant in the mix:

Dim myArray() As String = {"'ABC'","'DEF'","'GHI'","'JKL'","'MNO'"}