I have a text file with the following contents:

Andrew Law 32 6'1 123 Pounds Tom Harris 19 5'5 180 Pounds Randy Poffo 45 5'3 141 Pounds

Now on my form i have a listbox and four labels.

What i would like to do is have the listbox show only the names of the people in the text file (Andrew Law, Tom Harris, Randy Poffo) and when the user clicks the persons name in the listbox i would like each of the labels to show the corresponding details for that person (one label showing age, one showing their height and one showing their weight.)

I'm aware i could do this with a database however i would much prefer doing it by creating an array or list.

Any help would be so much appreciated!

Recommended Answers

All 2 Replies

You've tagged this with both vb.net and vb6 but need to write what you need here. Such as are you looking for a finished app with source code or are you stuck with how to read a file? Vb.net and vb6 syntax vary so you should pick one and not both.

commented: Sorry about that, i'm new to this. How do i edit and select just one? I am looking for finished app with source code. +0

And that "one" should not be VB6.

A couple of approaches, all of which involve reading each line and Splitting on the space that separates each field. Create a SortedList where the key is the name and the value is an array of the remaining elements. Copy the names to a listbox and when the user selects one, use that value as the key in SortedList to retrieve the remaining fields to populate the display.

Another would be essentially the same except you create a Class to define the fields instead of an array.

There are a lot of ways to approach this. You just have to pick one that suits your skill level.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.