My project is to use a one-dimensional array to solve following:
Read in 20 numbers, each of which is between 10 and 100 inclusive. As each number is read, display it in NumbersEnteredListBox and if it's not a duplicate of a number already read, diplay it in UniiqueValuesListBox. Provide "worst case" all 20 numbers are different. Use smalled possible array to solve problem.
Public Function RemoveDups(strings() As String) As String() Dim old_i As Integer Dim last_i As Integer Dim result() As String ' Make the result array. ReDim result(1 To UBound(strings)) ' Copy the first item into the result array. result(1) = strings(1) ' Copy the other items last_i = 1 For old_i = 2 To UBound(strings) If result(last_i) <> strings(old_i) Then last_i = last_i + 1 result(last_i) = strings(old_i) End If Next old_i ' Remove unused entries from the result array. ReDim Preserve result(1 To last_i) ' Return the result array. RemoveDups = result End Function
I want to understand what I'm learning so it will stick. What is Ubound? I realize I need to rewrite some of this to fit to what I'm trying to accomplish, but I want to understand it first. This is not in the book thus far. The codes I have found were sorry...horrible...I want to learn to write better with less words if possible?