Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays and List Boxes

Status
Not open for further replies.

godspeed06

Vendor
Apr 7, 2006
34
US
I have constructed a 2-dimensional array from which I am populating list boxes. At the moment I am having trouble understanding how to go about populating three list boxes based on the selection from the four list boxes. Example, in list box A I have names of cities read in from a “.dat” from my 2-dimensional array. Now, based on what city the user “selects” from list box A, I want search for a match on the city, and populate its value in list box city it matching country in list box country and lastly its population in list box population.

Is there a straight for method for accomplishing such a task?

Many thanks!
 
My recommendation, use a datatable. If you have a datatable with a city column, you can use datatable.find("City = '" & cmbCity.text & "'") to return an array of datarows that have the city value you are looking for.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Well the problem here is that I have an array already with neccessary data. I just need a way for populating the list boxes.
 
Something like this?

Code:
dim i as integer
for i = 0 to MyArray.Ubound(0)
  if MyArray(i) = cmbCity.Text then
    dim j as integer
    for j = 0 to MyArray.Ubound(1)
      'do something with MyArray(i,j)
    next j
  end if
next i

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick, I will try this and let you know how it work for me --thanks again!
 
Rick, It appears that the getUpperBound is available instead of .Upper(0) anyways I have “sorted” set to true for all my list boxes. However, when I match City and country they are not align with correct city and county with sorted enabled. I have a one-dimension array that hold the population count for the cities and countries, now that I have a “total population button” and label for their results, is there a straight forward way for capturing the totals in the label for “all” populations?

Many Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top