borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (mdiform + activex)Next Topic (How to catch the exception in VC++) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : Property arrays??? Solved Topic
Poster Message
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151

icon Property arrays???

Hi guys,
I have to develop a simulation of an air traffic controller. The trouble has come up like this:
I have 3 components of my project:
1) The Aircraft control (a custom made control taht has properties such as height, speed etc...)
2) The main form (on which the aircrafts move according to their properties eg from Origin=9 to destination =0)
3) The radar, which is basically a timer control, which checks the database on every tick, for newentries into the airspace.

What i want:
Any method by which i can store the projected route that the aircraft will follow. The route will b a structure something like this:
Aircraft.Projection.Height
Aircraft.Projection.x
Aircraft.Projection.y
Aircraft.Projection.Time

How do i implement this?  I know u'd laugh, but is there any thing such as Property Arrays   
Please guys, HELP ME!!!

____________________________
lOsT...

17-06-2005 at 12:01 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Property arrays???

You can easily implement this with classes. Example

clsAircraft code

Option Explicit

Private m_Projection As clsProjection

Public Property Get Projection() As clsProjection
    Projection = m_Projection
End Property

Public Property Set Projection(Value As clsProjection)
    m_Projection = Value
End Property


clsProjection code

Option Explicit

Private m_Height As Long
Private m_X As Long
Private m_Y As Long
Private m_Date As Date

Public Property Get Height() As Long
    Height = m_Height
End Property

Public Property Let Height(Value As Long)
    m_Height = Value
End Property

Public Property Get X() As Long
    X = m_X
End Property

Public Property Let X(Value As Long)
    m_X = Value
End Property

Public Property Get Y() As Long
    Y = m_Y
End Property

Public Property Let Y(Value As Long)
    m_Y = Value
End Property

Public Property Get Time() As Date
    Time = m_Time
End Property

Public Property Let Time(Value As Date)
    m_Time = Value
End Property


and this is how it will look from from code

Dim Aircraft As New clsAircraft

    Aircraft.Projection.Height=100


____________________________
If you find the answer helpful, please mark this topic as solved.

17-06-2005 at 02:20 PM
View Profile Send Email to User Show All Posts | Quote Reply
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151
icon Re: Property arrays???

Hi,
thanx for the quick reply.. but i'm sorry i couldnt explain the situation correctly   . My projection is for the next 100 seconds, that means some thing like this
Aircraft.Projection.Height(0) = 100
Aircraft.Projection.Height(1) = 101
Aircraft.Projection.Height(2) = 102
-
-
-
Aircraft.Projection.Height(99) = 150
and also
Aircraft.Projection.Time(0) = "10:15:00 AM"
and so on, and then, x and y
So thats y i asked for property arrays or anything of that sort...
In the example u've given, can i define the m_Projection as an array like this:

Private m_Projection(99) As clsProjection


Moreover can classes have a visual image? Like a circle, or something on the form (just like controls can..)?

Thnx anywayz for the quick reply
Bye

[Edited by misterxed on 17-06-2005 at 08:15 PM GMT]

____________________________
lOsT...

17-06-2005 at 07:49 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Property arrays???

Aha, now I got you.

quote:
In the example u've given, can i define the m_Projection as an array like this:

Private m_Projection(99) As clsProjection


Yes, you can create an array of objects, but you need to specify New keyword.

quote:
Moreover can classes have a visual image? Like a circle, or something on the form (just like controls can..)?


No, class doesnt have an interface.

quote:
Aircraft.Projection.Height(99) = 150


This is not the same as creating an array of objects. If you are creating an array of objects, like

dim a(10) as new clsprojection


then it means you will have 10 projection objects, but each wil have only one value for height property.

If you want to create a property array, which is a different thing, then you would do it like this

clsprojection code

Option Explicit

Private m_Height(10) As Long

Public Property Get Height(index As Long) As Long
    Height = m_Height(index)
End Property

Public Property Let Height(index As Long, Value As Long)
    m_Height(index) = Value
End Property


then you can have multiple (10) values for height

dim p as new clsprojection

    p.height(0)=10
    p.height(1)=15
    p.height(2)=20
    ' etc etc




____________________________
If you find the answer helpful, please mark this topic as solved.
18-06-2005 at 12:59 AM
View Profile Send Email to User Show All Posts | Quote Reply
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151
icon Re: Property arrays???

Thanx for the help Goran... but i'm still stuck!!!  
Heres the situation now:

U told me that the problem cud b solved by using class objects. I made the Projection class jsut as u sed

quote:


clsprojection code

Option Explicit

Private m_Height(10) As Long

Public Property Get Height(index As Long) As Long
    Height = m_Height(index)
End Property

Public Property Let Height(index As Long, Value As Long)
    m_Height(index) = Value
End Property



(and the rest of the properties as well (x, y, and date...)

but i didnt make the Aricraft class. Instead i've made an Activex Control, and put the same code as u sed to put in the aircraft class (cuz i need a visual interface for the aircraft)

heres the problem:
it works fine when i'm running the app, but when i try to add values to the height, x,y, & date arrays, it gives the following error:

Runtime error 91
Object Variable or With block variable not set


When i click on Debug, it goes to:
Property Get Projection() as clsProjection

in the Aircraft activex, and when i point to the
Projection = m_Projection

line, it says Projection = Nothing

Help PLEASE    

____________________________
lOsT...
18-06-2005 at 08:14 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Property arrays???

Sorry, it was my mistake, didnt have time to test the code. I forgot class initialize event:

add this code to clsAircraft
private sub class_initialize()
    set m_projection=new clsprojection
end sub

' and also correct this line of code
Public Property Get Projection() As clsProjection
    Set Projection = m_Projection
End Property




____________________________
If you find the answer helpful, please mark this topic as solved.

18-06-2005 at 08:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151
icon Re: Property arrays???

Hi,
I just wanted to thank u for being the great help that u've been.... Keep up the good work pal  
To u, it might only be a REPLY.. But it might b a life saver for others So, THANK YOU!

____________________________
lOsT...

23-06-2005 at 03:07 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ActiveX : Property arrays??? Solved Topic
Previous Topic (mdiform + activex)Next Topic (How to catch the exception in VC++) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder