r/visualbasic • • Apr 04 '16

[Homework] I need help with this assignment. I don't know how to start

http://imgur.com/PBuOgKH
0 Upvotes

5 comments sorted by

1

u/CharlieMay VB.Net Intermediate Apr 04 '16

The answer will depend on what you are expected to use to perform this. Most ways are going to be pretty easy. I'm going to assume that you are to use an array to store the inputted values as this would only be a couple of lines of code with a generic list. What you would do is create a loop with an input box. With each iteration of the loop, check to see if the value is already in the array (looping through the array and checking for equality against the input). If not, add the input to the array and repeat. If it is already there then you just need to loop through the array and add the elements to the listbox and set the label to the count of the array.

1

u/BestiaItaliano Apr 04 '16

Learn to work with arrays and check out the filter function

1

u/nerdfarm Apr 04 '16

At first glance this looks simple, but you need to have the user enter at least one number before you can do any comparison. Use a list. Have the user enter one number to start and add it to the list. After the first number is entered, for each subsequent number:

Check the list for a match each time the user enters a new number. If there is no match then add the number to the list. If there is a match then loop through the list and add the numbers to the listbox.

1

u/BestiaItaliano Apr 05 '16

I would convert the values to strings and populate an array using the filter function after each entry to check for duplicates and adding the new values if not found or populating the list when a duplicate is found.

It about 5 minutes of code

1

u/nerdfarm Apr 05 '16

You'd have to re-dimension the array every time a new number is to be added, unless the new number is a duplicate.