Hello,
I'm working my way through "Visual Basic 2003 in so and so many days".
At the same time I'm trying to create a windows application and I'm a little
impatient.
I have the folowing problem:
I have different shafts that consist of a diameter, a color, a lenght, and a
factor.
I'd like to define the shafts so that I can identify them by inputing the
diameter and the color.
So dia. 2" and color green would give me lenth 12" and factor 4. I have
about 50 dia. and 3 colors
and the according lenght nd factor.
I was thinking about something like
lenght = shaft.diameter.color.lenght
factor=shaft.diameter.color.factor
How would one define these shafts and retrieve the information?
Thanks,
Jerry 4 1985
You would need to create new classes to represent the shafts as
objects. Sounds like you could create one class and then call a new
instance of that class for each diff type of object. There is a lot
that can be done with this but here is a start..
Public Class Shaft
Private _diameter As Decimal
Private _color As String
Private _length As Decimal
Private _factor As Decimal
Public Property Diameter() As Decimal
Get
Return _diameter
End Get
Set(ByVal Value As Decimal)
_diameter = Value
End Set
End Property
'do this for each Property you want to access
Public Sub New(ByVal diameter As Decimal, ByVal color As String, ByVal
length As Decimal, ByVal factor As Decimal)
_diameter = diameter
_color = color
_length = length
_factor = factor
End Sub
End Class
Then in your application create an instance of the shaft like this...
Dim objShaft As New Shaft(2, "Green", 12, 4)
access the properties of your object like so...
mylength = objShaft.Length
This is only a start and a very basic example, but something you can
work with.
A structure, as opposed to a class, may be another option for this.
"Charlie Brown" <cb****@duclaw.com> wrote in message
news:11**********************@j55g2000cwa.googlegr oups.com... You would need to create new classes to represent the shafts as objects. Sounds like you could create one class and then call a new instance of that class for each diff type of object. There is a lot that can be done with this but here is a start..
Public Class Shaft
Private _diameter As Decimal Private _color As String Private _length As Decimal Private _factor As Decimal
Public Property Diameter() As Decimal Get Return _diameter End Get Set(ByVal Value As Decimal) _diameter = Value End Set End Property
'do this for each Property you want to access
Public Sub New(ByVal diameter As Decimal, ByVal color As String, ByVal length As Decimal, ByVal factor As Decimal) _diameter = diameter _color = color _length = length _factor = factor End Sub
End Class
Then in your application create an instance of the shaft like this...
Dim objShaft As New Shaft(2, "Green", 12, 4)
access the properties of your object like so...
mylength = objShaft.Length
This is only a start and a very basic example, but something you can work with.
Thanks Charlie,
I'll try this out. I did think it was possible to put them all in one I
guess class.
I just don't know how.
Mike, what is a structure?
Thanks,
Jerry
"Mike Lowery" <se******@mouse-potato.com> schrieb im Newsbeitrag
news:ee**************@TK2MSFTNGP03.phx.gbl... A structure, as opposed to a class, may be another option for this.
"Charlie Brown" <cb****@duclaw.com> wrote in message news:11**********************@j55g2000cwa.googlegr oups.com... You would need to create new classes to represent the shafts as objects. Sounds like you could create one class and then call a new instance of that class for each diff type of object. There is a lot that can be done with this but here is a start..
Public Class Shaft
Private _diameter As Decimal Private _color As String Private _length As Decimal Private _factor As Decimal
Public Property Diameter() As Decimal Get Return _diameter End Get Set(ByVal Value As Decimal) _diameter = Value End Set End Property
'do this for each Property you want to access
Public Sub New(ByVal diameter As Decimal, ByVal color As String, ByVal length As Decimal, ByVal factor As Decimal) _diameter = diameter _color = color _length = length _factor = factor End Sub
End Class
Then in your application create an instance of the shaft like this...
Dim objShaft As New Shaft(2, "Green", 12, 4)
access the properties of your object like so...
mylength = objShaft.Length
This is only a start and a very basic example, but something you can work with.
http://www.informit.com/articles/art...p?p=25864&rl=1
"Jerry" <je******@gmx.net> wrote in message
news:e6*************@news.t-online.com... Thanks Charlie,
I'll try this out. I did think it was possible to put them all in one I guess class. I just don't know how.
Mike, what is a structure?
Thanks,
Jerry
"Mike Lowery" <se******@mouse-potato.com> schrieb im Newsbeitrag news:ee**************@TK2MSFTNGP03.phx.gbl...A structure, as opposed to a class, may be another option for this.
"Charlie Brown" <cb****@duclaw.com> wrote in message news:11**********************@j55g2000cwa.googlegr oups.com... You would need to create new classes to represent the shafts as objects. Sounds like you could create one class and then call a new instance of that class for each diff type of object. There is a lot that can be done with this but here is a start..
Public Class Shaft
Private _diameter As Decimal Private _color As String Private _length As Decimal Private _factor As Decimal
Public Property Diameter() As Decimal Get Return _diameter End Get Set(ByVal Value As Decimal) _diameter = Value End Set End Property
'do this for each Property you want to access
Public Sub New(ByVal diameter As Decimal, ByVal color As String, ByVal length As Decimal, ByVal factor As Decimal) _diameter = diameter _color = color _length = length _factor = factor End Sub
End Class
Then in your application create an instance of the shaft like this...
Dim objShaft As New Shaft(2, "Green", 12, 4)
access the properties of your object like so...
mylength = objShaft.Length
This is only a start and a very basic example, but something you can work with.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: s |
last post by:
Can I do this:
#define MYSTRING "ABC"
..
..
..
char mychar = MYSTRING;
..
..
..
|
by: Peng Yu |
last post by:
I want to define a macro
#define FILEWR(FILENAME)
which can be expanded to
#ifndef OUTFILE
#define OUTFILE
ofstream out;
#endif
|
by: Bryan Parkoff |
last post by:
"#define" can only be inside the global scope before main() function.
"#if" can be tested after "#define" is executed. The problem is that
"#define" can't be inside main() function. I do not wish...
|
by: MakisGR |
last post by:
I'm having trouble understanding what the following define does. Can
anyone provide some assistance?
#define SetBits(bits,pos) (((bits)) |= (1 << ((pos) &
7)))
--
comp.lang.c.moderated -...
|
by: baumann |
last post by:
hi all,
typedef int (*pfunc)(int , int);
pfunc a_func;
i know it's ok,
but how can define a_func without typedef statement?
thanks .
|
by: **Developer** |
last post by:
I always define events with the parameters
ByVal sender As Object, ByVal e As EventArgs
Even if they are not used.
Seems I read someplace that's the thing to do.
So I then do:
|
by: eiji |
last post by:
Hi folks,
I hope this is not "off topic"! :-)
Consider the next code:
/* Declarations of types that could become platform-dependent */
#define MyChar char
#define MyInt int
|
by: raghu |
last post by:
#define GOOGLE
int main(void)
{
printf("%d",GOOGLE);
return 0;
}
In the above program ,by default GOOGLE should be assigned to
zero..right?
But when I try to print it it gives an error at...
|
by: alan |
last post by:
Hello world, I'm wondering if it's possible to implement some sort of
class/object that can perform mapping from class types to strings?
I will know the class type at compile time, like so:...
|
by: sophia |
last post by:
Dear all,
the following are the differences b/w #define and typedef ,which i
have seen in Peter van der lindens book. is there any other difference
between thes two ?
The right way to...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
| |