Reading Min & Max Vals. 
Author Message
 Reading Min & Max Vals.

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



Fri, 10 Sep 2004 22:55:44 GMT  
 Reading Min & Max Vals.
What does the data in your text file look like? How are you parsing it now when you load
it into the ListBox?

Rick


Quote:
> 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



Fri, 10 Sep 2004 23:24:06 GMT  
 Reading Min & Max Vals.
Not knowing the structure of your data the basic advice would be
to parse the text data line go get what you need.

pete

Quote:

> 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



Fri, 10 Sep 2004 23:16:17 GMT  
 Reading Min & Max Vals.
"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

Quote:
> 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



Fri, 10 Sep 2004 23:58:05 GMT  
 Reading Min & Max Vals.
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


Quote:
> "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



Sat, 11 Sep 2004 01:41:13 GMT  
 Reading Min & Max Vals.
had to make some changes to get it to do what i wanted it to.  decided to
stick with the loop, as this was the way ill be expected to hand it in as,
but other than that it worked.  thanks!!

Quote:
> 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



Sat, 11 Sep 2004 02:30:59 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. MIN & MAX functions on date fields

2. MIN & MAX thru code

3. Graph Axis Min & Max

4. Min & Max Values on Axis

5. Accessing and Changing IE30 Min & Max Buttons

6. min and max

7. Keeping Access Open - System Modal Min/Max

8. Setting min and max values on chart's y-axis

9. Programming the min and max values of an axis

10. Setting Min and Max Scale for MSGraph8, also marker style and color

11. Keeping Window open and available - SysModal - Min/Max

12. textbox character input max/min

 

 
Powered by phpBB® Forum Software