I would like to use nested tokens.

For example entering the following into textbox1:
{red | green | blue | yellow}

and pressing a command button could randomly place one of the above colors into textbox2 each time it is pressed.

I would like to do the above as an example an will then implement it into my program.


(by the way, I am new to daniweb, I used to use vbforums.com however "jmcilhinney" dominates the .net section and leaves extremely vague responses which is very non-productive)

Thank you all in advance!

All of the threads after me are receiving responses except mine. Is my question too technical?

All of the threads after me are receiving responses except mine. Is my question too technical?

No. Sometimes it just takes a while for someone to come by. Most of us actually have lifes, so we're not on-line 24/7.

Now for you problem:
You need to split the string in seperate colors, and then pick one of them by random.
Here's an example:

Dim RandomClass As New Random()
        Dim input As String = "red | green | blue | yellow"
        Dim colors As String()
        colors = input.Split("|")

        Dim RandomNumber As Integer
        RandomNumber = RandomClass.Next(0, 4)

        MessageBox.Show(colors(RandomNumber))

If you have any questions, please repost.

Niek

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.