0

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!

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Nick Evan
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.