|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Class/Structure/EnumI posted here a few days ago (thanks Charlie and Mike). I'm not sure if I clearly asked for what I need or just don't understand the solutions. I have different types of available shafts. They are catogorized by diameter and color. The different combinations of diameter and color result in different lenths and different factors. So a green shaft with 2" dia. is 36" long and has a factor of 2. The same dia. but red is only 32" long but has the same factor. I'd like to make "something" so that when the user inputs a diameter and color he gets the next smallest available diameter, lenght and factor of a shaft. I don't want if dia>=2 and color = "green" then dia=2 lenght=36 factor=4 else if dia>=2 and color="red" then dia=2 lenght=32 factor=4 else if dia>=1.75 and color="green" then dia=1.75 lenght=30 factor=3.5 so on and on. Charlie and Mike, I don't understand how to do this with your solutions. Thanks, Jerry Hello Jerry,
Your best bet will be a database. Two tables should be sufficient. 1. Colors (ColorID, Name) 2. Shafts (ShaftID, ColorID, Diameter, Length, Factor) Then after you fill in the data you can ask the database what the next one would be. SELECT TOP 1 Shafts.* FROM Shafts, Colors WHERE (Shafts.ColorID = Colors.ColorID) AND (ColorID = ***COLOR ID HERE***) AND (Diameter <= ***DIAMETER HERE***) ORDER BY Diameter DESC This will give you the matching color/diameter.. or if there isnt one, the next smallest. No need for an object hierarchy at all. -Boo Show quoteHide quote > Hello, > > I posted here a few days ago (thanks Charlie and Mike). > I'm not sure if I clearly asked for what I need or just don't > understand the > solutions. > I have different types of available shafts. > They are catogorized by diameter and color. > The different combinations of diameter and color result in different > lenths > and different factors. > So a green shaft with 2" dia. is 36" long and has a factor of 2. > The same dia. but red is only 32" long but has the same factor. > I'd like to make "something" so that when the user inputs a diameter > and color he gets the next smallest available diameter, lenght and > factor of a shaft. > > I don't want > > if dia>=2 and color = "green" then > dia=2 > lenght=36 > factor=4 > else if dia>=2 and color="red" then > dia=2 > lenght=32 > factor=4 > else if dia>=1.75 and color="green" then > dia=1.75 > lenght=30 > factor=3.5 > so on and on. > > Charlie and Mike, I don't understand how to do this with your > solutions. > > Thanks, > > Jerry > |
|||||||||||||||||||||||