> Parsing is the method you break a string of text up into smaller pieces
(as you have now
> shown us). If I've got everything straight, this Click event for you
lstPatients ListBox
> should do what you want (written off the top of my head, so be sure to
check it out). The
> first loop finds the clicked on name in your stored list of records. Doing
this allows you
> to set the Sorted property for the ListBox to True. Instead of the loop,
you could have
> stored the Indexes in each item's ItemData property at the time the item
is read it. This
> would have allowed you to read the value immediately without the loop.
Another thing you
> might want to look into is dynamic arrays. With them, you would not have
to hard-code the
> Maxpatients constant which, in turn, would let you add or remove patients
from you text
> file without have to recompile this program each time.
> Rick
> Private Sub lstPatients_Click()
> Dim Min As Integer
> Dim Max As Integer
> Dim Index As Integer
> ' Get patient index
> For X = 1 To Maxpatients
> If lstPatients.List(lstPatients.ListIndex) = _
> Patients(X).PatientName Then
> Index = X
> Exit For
> End If
> Next
> ' Find Min and Max
> Min = Patients(Index).HeartRate(1)
> Max = Patients(Index).HeartRate(1)
> For X = 2 To 7
> If Patients(Index).HeartRate(X) > Max Then
> Max = Patients(Index).HeartRate(X)
> End If
> If Patients(Index).HeartRate(X) < Min Then
> Min = Patients(Index).HeartRate(X)
> End If
> Next
> ' The variable Min and Max now contain the
> ' minimum and maximum heartrates for the
> ' patient whose name was click in the ListBox,
> ' so...you can now do something with them.
> End Sub
message
> > "1000","Gary Lawson",112,110,120,114,116,109,107
> > ^ code. ^ name ^ heart rate
> > not used, shown in to be displayed in labels
> > but loaded list box
> > into table
> > this is an example of the data ill be using. what is parsing? im new to
> > this. The name only is being read into the list box, but the data is
being
> > held in a table. Upon clicking on the name, i have 3 labels, min, max
and
> > average. i also have a button, "Next", which when clicking will load
the
> > first number into the boxes, then clicking again wil load the second
number
> > in. I wat to beable to read the minimum value from the data so far, and
> > also the maximum. The average i already know how to do.
> > this is the code i have on form load
> > Dim filename As String
> > Dim filenumber As Integer
> > filename = App.Path & "\patients.txt"
> > filenumber = FreeFile
> > Open filename For Input As #filenumber
> > Do While (Not EOF(filenumber)) And index < Maxpatients
> > index = index + 1
> > Input #filenumber, patients(index).patientID,
> > patients(index).patientname
> > For index2 = 1 To 7
> > Input #filenumber, patients(index).heartrate(index2)
> > Next
> > lstPatients.AddItem patients(index).patientname
> > Loop
> > this is my module
> > Const days = 7
> > Public Const Maxpatients = 20
> > Type tpatients
> > patientID As String * 4
> > patientname As String
> > heartrate(1 To days) As Integer
> > End Type
> > Public patients(1 To Maxpatients) As tpatients
> > hope this helps
> > > What does the data in your text file look like? How are you parsing it
now
> > when you load
> > > it into the ListBox?
> > > Rick
> > message
> > > > Hi!
> > > > I hope someone here can help me out with a little problem I have.
> > > > I have a text file containing data which is being loaded into a list
> > box.
> > > > e.g runners in a race. on selection of one particular piece of
data,
> > i.e
> > > > the name, i want to be able to take a minimum value and maximum
value
> > from
> > > > the corresponding data ie lap speeds. can anyone help me?
> > > > thanks
> > > > christine