If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Classes and Interfaces.... Code included, what is wrong...?

A) read the points (X1, Y1, X2, Y2 and so on) of a shapeline and store them
B) divide the line(s) in parts of 10meter and being able to assign values to each part

I have trouble to convert the old vb6 approach with TYPES and arrays and DIMs to visual studio. So far I did this.... for GOAL A.

I have made a class, which you will find below, where I declared all variables used by using an interface..... the array containing the coordinates must be public... so it coordinates could be used in drawingroutines...

Code:

BaanShapePuntDecl

Then I made a second class which handles reading the shapefile. And suddenly it gets confusing... I will implement only the relevant parts of the code below....

The question is, will this work, or are there any big mistakes as I assume/feel there are.....

Below the declaration interface of the lineshape points

Code:

Public Class BaanShapePuntDecl
REM ************************************************
REM * Variable for the shape axis
REM ************************************************
Implements iBaanShapePunt
Public Interface iBaanShapePunt
Property X1lineShape As Single
Property Y1lineShape As Single
Property X2lineShape As Single
Property Y2lineShape As Single
End Interface
Public arraylist As iBaanShapePunt
Sub New(ByVal a, ByVal b, ByVal c, ByVal d)
a = X1lineShape
b = Y1lineShape
c = X2lineShape
d = Y2lineShape
End Sub
Public Property X1lineShape As Single Implements iBaanShapePunt.X1lineShape
Get
Return X1lineShape
End Get
Set(ByVal value As Single)
End Set
End Property
Public Property X2lineShape As Single Implements iBaanShapePunt.X2lineShape
Get
Return X2lineShape
End Get
Set(ByVal value As Single)
End Set
End Property
Public Property Y1lineShape As Single Implements iBaanShapePunt.Y1lineShape
Get
Return Y1lineShape
End Get
Set(ByVal value As Single)
End Set
End Property
Public Property Y2lineShape As Single Implements iBaanShapePunt.Y2lineShape
Get
Return Y2lineShape
End Get
Set(ByVal value As Single)
End Set
End Property
End Class

Re: Classes and Interfaces.... Code included, what is wrong...?

1) Who set your GOAL? You or a teacher?
2) Have you TRIED to execute the code?
3) If the answer is NO to #2, then try that, POST the code with the ERROR LINE and MESSAGES.
4) Put mouse over ERROR, click and press F1 for help. Attempt to resolve errors, YOURSELF (You'll feel better)
5) If stuck, then ask a question.

Re: Classes and Interfaces.... Code included, what is wrong...?

I am not a student, im an emplyee at www.movares.nl in the netherlands.. I am not a programmer but teached myself vb6 to programm fast tools to enlighten my work

Since a few weeks i decided to step towards vb2010 and as i saw that i could programm in the same style as vb6 i decided - to try at least- to programm in OOP....

I bought books and spended already many many hours to try to step away from my vb6 approach..... I made already a working part of teh programm i am working on but things getting complex fast due to the way u could use class.... it feels you have so many options that it starts puzzling me..... in this example i start using an interface....

If noone can see if its well done how i classed things than i will make a mini programm to test this but i feel it would take me many many hours to find out whats wrong.... I still refuse to proramm it in a vb6 style...

I also checked dozens of examples, tried approaches with dims, arraylists, structures and such.... I just want a push in the good direction )

Re: Classes and Interfaces.... Code included, what is wrong...?

Well you point out my struggle with vb2010..... I see so many examples and read so many things about it and it feels as if there are a 100 ways to build the bridge, some say use steel, some wood, some say use all these things... (

in vb6 i uses TYPE....END TYPE and a DIM statement like
TYPE elements
wood as integer
steels as integer
END TYPE
dim bridge(0 to 10) as element

but right now after about 50 hours of OOP i am still confused ( and i refuse to misuse OOP and programm VB2010 as it were VB6....

Re: Classes and Interfaces.... Code included, what is wrong...?

Thanx , believe me I started with structures but i was told to use properties and i read a book which advised to use an interface...... so in my first attempt (actually i have a nice working part of my programm) i stumble over storing and retrieving array-able data.....

Re: Classes and Interfaces.... Code included, what is wrong...?

Hooray, I solved it this way...... it works fine but now i want to ask a few things about the theory of this....

I used a Module to store the structure (like in VB6) is this a good way to go?

Code:

Module DMCviewerModule
REM ************************************************
REM * Variable for the shape axis
REM ************************************************
Public Structure BaanShapePunt
Public X1lineShape As Single
Public Y1lineShape As Single
Public X2lineShape As Single
Public Y2lineShape As Single
End Structure
End Module

Then I use this on my mainform, is this correct technically, it felt for me )

Class, property and code included, what is wrong? one step away from a working prog

Hello I have still problems in understanding combinations of a class and a list defined in it

Below you see 3 parts of my programm, with only relevant code
1 First a class with properties, see first part... this works
2 Than a subprogramm where some values are assigned to a list, second part... this full part works
3 Than a subprogramm where i need values out the list....full code below in the last part, here it goes wrong

It fails on this 3rd point as it does not know Bakjeslijst at that point but what i try (using dim and such), i can not get it working.... in some solution its error free but it can not retrieve a list.count > 0...

Any of you know what is going wrong... it is a nooby mistake, that i am sure of )

Thx Joska

Code:

Public Class Class_BaanAsBakje
REM ************************************************
REM * Fields voor de bakjes van de baan
REM ***********************************************
Private mIDbakje As Long
Private mX1bakje As Single
Private mY1bakje As Single
Private mX2bakje As Single
Private mY2bakje As Single
Private mLengte As Single
Private mReductiepuntenLinks As Long
Private mReductiepuntenRechts As Long
REM ************************************************
REM * Properties voor de bakjes van de baan
REM ************************************************
Public Property IDbakje As Long
Get
Return mIDbakje
End Get
Set(ByVal value As Long)
mIDbakje = value
End Set
End Property
Public Property X1bakje As Single
Get
Return mX1bakje
End Get
Set(ByVal value As Single)
mX1bakje = value
End Set
End Property
Public Property Y1bakje As Single
Get
Return mY1bakje
End Get
Set(ByVal value As Single)
mY1bakje = value
End Set
End Property
Public Property X2bakje As Single
Get
Return mX2bakje
End Get
Set(ByVal value As Single)
mX2bakje = value
End Set
End Property
Public Property Y2bakje As Single
Get
Return mY2bakje
End Get
Set(ByVal value As Single)
mY2bakje = value
End Set
End Property
Public Property Lengte As Single
Get
Return mLengte
End Get
Set(ByVal value As Single)
mLengte = value
End Set
End Property
Public Property ReductiepuntenLinks As Long
Get
Return mReductiepuntenLinks
End Get
Set(ByVal value As Long)
mReductiepuntenLinks = value
End Set
End Property
Public Property ReductiepuntenRechts As Long
Get
Return mReductiepuntenRechts
End Get
Set(ByVal value As Long)
mReductiepuntenRechts = value
End Set
End Property
REM ************************************************
REM * VULLEN VANUIT DE OPKNIPPER
REM ************************************************
Public Sub New(ByVal IDbakje As Long, ByVal X1bakje As Single, ByVal Y1bakje As Single, ByVal X2bakje As Single, ByVal Y2bakje As Single, ByVal lengte As Single)
mIDbakje = IDbakje
mX1bakje = X1bakje
mY1bakje = Y1bakje
mX2bakje = X2bakje
mY2bakje = Y2bakje
mLengte = lengte
End Sub
End class

This will dynamically create an array of Coordinate with the specified count. Note that you should not do "BakjesLijst.Count - 1" in the code since Array.CreateInstance() will create the correct amount elements.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.