Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27474

VS 2010 Adding items to a String array, from an existing array

$
0
0
Here's my code. Sorry for the awful conventions, but they are meant to be like this.

Code:

      Public Function charliebrown() As String
        Randomize()
        Dim charlie() As String = New String() {"billyboy", "shoppingmall", "cookingtime", "halfbaked", "benandJerrys", "alaska", "northernstates", "america", "loltakethat!"}
        Dim picked As String = charlie(Rnd)

        For count = 0 To applepicked.Length - 1

            For counter = 0 To charlie.Length - 1
                While applepicked.ToString.Contains(picked) = False And applepicked.Length <> 5

                    applepicked(count) = picked
                End While

                'Return applepicked(Rnd)
            Next
        Next

End Function

What I'm trying to do is add a random String from charlie(), and add it to applepicked().

If applepicked already has the the String chosen, it will choose a different String.

It will loop until the length of the array is 5.

There is my horrible attempt.

Can someone please fix it up?

At the moment it's not adding the strings to the new array

Viewing all articles
Browse latest Browse all 27474

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>