locked
Help with classes, Interfaces and such, code included! vb2010 RRS feed

  • Question

  • Goal

    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...

    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....

    Imports DMCviewer.BaanShapePuntDecl

    Public class ReadBaanShapePoint Private Sub LeesBAANASLijnen(ByVal FileNumber As Integer, ByRef Offset As Long, ByVal FileType As Integer)

    Dim iBaanShapePunt() As BaanShapePuntDecl
    Dim Vertex as long

    for count = 200 to 275
    Vertex += 1
              iBaanShapePunt(vertex).X1lineShape = CSng(X1)
              iBaanShapePunt(vertex).X2lineShape = CSng(X2)
              iBaanShapePunt(vertex).Y1lineShape = CSng(Y1)
              iBaanShapePunt(vertex).Y2lineShape = CSng(Y2)
    next
    End sub


    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

    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

    Tuesday, September 11, 2012 5:21 PM

Answers

  • Well i just noticed i solved a part of it,  the code below works BUT structure doesnt allow to store the data a "second time" or you must make workaround....  this is what worked if u just have to store data....

    But after storage of the data I wasnt allowed to change for example the Z-value of the collection..... so right now i composed a class and a list-statement.... which left me puzzled again as well and i will open a new thread for this new subject.... :o(

    I just miss the old VB6 command TYPE....END TYPE with a DIM AS..

        Public Structure BaanShapePunt
            Public XlineShape As Single
            Public YlineShape As Single
            Public Lengte As Single
            Public km As Single
            Public Structureshape As Long
            Public Z As Single
        End Structure
        Public BaanPunten As New List(Of BaanShapePunt)
    
    *************** PART OF MAIN PROGRAMM
    Dim BaanPunt As BaanShapePunt
    
    BaanPunt.XlineShape = CSng(X1)
    BaanPunt.XlineShape = CSng(X2)
    BaanPunten.Add(BaanPunt)
    *************************************
    

    Thursday, September 13, 2012 5:33 PM

All replies

  • Solved!
    • Marked as answer by Joska Paszli Wednesday, September 12, 2012 8:52 AM
    • Unmarked as answer by Youen ZenModerator Thursday, September 13, 2012 9:21 AM
    Wednesday, September 12, 2012 8:52 AM
  • Hi Joska,

    Glad to hear you've solved your problem. Could you please share your solution here? It will be helpful to other members that have same problem.

    Thanks in advance!


    Shanks Zen
    MSDN Community Support | Feedback to us

    Thursday, September 13, 2012 9:21 AM
    Moderator
  • Well i just noticed i solved a part of it,  the code below works BUT structure doesnt allow to store the data a "second time" or you must make workaround....  this is what worked if u just have to store data....

    But after storage of the data I wasnt allowed to change for example the Z-value of the collection..... so right now i composed a class and a list-statement.... which left me puzzled again as well and i will open a new thread for this new subject.... :o(

    I just miss the old VB6 command TYPE....END TYPE with a DIM AS..

        Public Structure BaanShapePunt
            Public XlineShape As Single
            Public YlineShape As Single
            Public Lengte As Single
            Public km As Single
            Public Structureshape As Long
            Public Z As Single
        End Structure
        Public BaanPunten As New List(Of BaanShapePunt)
    
    *************** PART OF MAIN PROGRAMM
    Dim BaanPunt As BaanShapePunt
    
    BaanPunt.XlineShape = CSng(X1)
    BaanPunt.XlineShape = CSng(X2)
    BaanPunten.Add(BaanPunt)
    *************************************
    

    Thursday, September 13, 2012 5:33 PM