vb.net - ArrayList in VB 2010 - What's wrong with my code? -


i wondering if point out going wrong code. working arraylist called nouns , have code adds word that's picked arraylist arraylist called newarray().

the trouble is, when sub called label_click event, doesn't keep words stored in newarray code newarray.add(wordchosen) is. found debugging it, using breakpoints , stepping.

the code part here:

sub getnoun()      dim nouns arraylist = new arraylist(16)     nouns.add("france")     nouns.add("bird")     nouns.add("doctor")     nouns.add("city")     ...      dim lblarray label() = {lblone, lbltwo, lblthree, lblfour}  start:     dim wordchosen string     wordchosen = nouns(random.next(16))      if newarray.contains(wordchosen)         goto start     else         dim labelchosen label         labelchosen = lblarray(random.next(4))         labelchosen.text = wordchosen         nouns.remove(wordchosen)         newarray.add(wordchosen)     end if end sub 

what keep words within dynamic arraylist? hope makes sense , isn't duplicate, stuck ideas.

your list local variable.

each time call function, fresh new variable.

you should move class create single field, , initialize in constructor.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -