473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Class/Structure/Enum

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
Jun 8 '06 #1
1 976
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
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

Jun 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
3
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
4
by: imme929 | last post by:
I got things working until I tried adding this enum to a structure... Public Enum Keyboard EnglishUS EnglishUK Spanish German Italian French
1
by: Ghislain Tanguay | last post by:
Hi, I have two structures. One containing(EmailMessage) an array of the other(AttFile). When I try to work with in my VB.NET app iIalways receive an error off this type Object reference not set to...
13
by: cgough | last post by:
My true programming language is C++. I am at best a VB6 hacker that is just getting into VB.NET. I have a quick question about when to new and when not to new. Consider the following 2 classes....
2
by: HockeyFan | last post by:
I have a class that has responses to a survey. Some questions have text answers, and some have enum answers (integer type). All have ResponseIDs. If I'm passed data in random order of...
3
by: Jim Langston | last post by:
I am attempting to map the variables in a class or structure to use with MySQL. I got something to work but I'm not happy with it. Here is a snippet showing what I'm not happy with: class...
4
by: shapper | last post by:
Hello, I have a class which I am using in my profile. I made this class Serializable by using: <Serializable()_ Public Class Options One of the properties in this class is of type Level...
1
by: Scott Stark | last post by:
What's the best way to represent data that exists in a grid structure? Let's say product #12345 is availabile in 3 colors, my grid might look like this: COLOR S M L ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.