Collections and Classes

jadox

New Member
Joined
Feb 16, 2014
Messages
38
Hi,

Can anyone help me with this?

I have a class, lets say with Name, Address and Salary properties. And a Collection (Employees) with all the classes.

Is there a way to search for the maxvalue of the Salary, from all the classes in the collection?

Thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try something like this...

<font face=Calibri>    <SPAN style="color:#00007F">Dim</SPAN> Employees       <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">New</SPAN> Collection<br>    <SPAN style="color:#00007F">Dim</SPAN> cEmp            <SPAN style="color:#00007F">As</SPAN> clsEmp<br>    <SPAN style="color:#00007F">Dim</SPAN> sEmployee       <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> MaxSalary       <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Double</SPAN><br>    <br>    <SPAN style="color:#007F00">'Your code to store class objects in your collection</SPAN><br>    <br>    MaxSalary = 0<br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cEmp <SPAN style="color:#00007F">In</SPAN> Employees<br>        <SPAN style="color:#00007F">If</SPAN> cEmp.Salary > MaxSalary <SPAN style="color:#00007F">Then</SPAN><br>            MaxSalary = cEmp.Salary<br>            sEmployee = cEmp.Name<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> cEmp<br>    <br>    MsgBox "Employee:  " & sEmployee & "; Salary:  " & MaxSalary<br>    </FONT>

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,215
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top