Solved

need to convert Property Get/Let to vb.net

Posted on 2010-09-14
4
814 Views
Last Modified: 2012-06-27
I'm a newby to vb.net even though I've done VBA and VB6 programming for several years. One feature I've seldom ever even used in VB6 is the Property statement.  So needless to say I'm having difficulty upgrading a particular project from vb6 to vb.net. I thought I would post  portion of my code here to see if someone wants to convert it to VB.net syntax. Hopefully by looking at what is done with this portion, then I'll know how to handle the rest of my statements.  Here's the code.

Property Let PDFSetZoomMode(pZoomMode As PDFZoomMd)
Attribute PDFSetZoomMode.VB_HelpID = 2009

    If pZoomMode = ZOOM_FULLPAGE Or pZoomMode = ZOOM_FULLWIDTH Or _
        pZoomMode = ZOOM_REAL Or pZoomMode = ZOOM_DEFAULT Or _
        (IsNumeric(pZoomMode) And (pZoomMode <> ZOOM_FULLPAGE Or _
                                    pZoomMode <> ZOOM_FULLWIDTH Or _
                                    pZoomMode <> ZOOM_REAL Or _
                                    pZoomMode <> ZOOM_DEFAULT)) Then
            If IsNumeric(pZoomMode) Then
                PDFZoomMode = Int(pZoomMode)
            Else
                PDFZoomMode = pZoomMode
            End If
    Else
        MsgBox "Incorrect Zoom Mode : " & pZoomMode & "." & _
                   vbNewLine & _
                   "Focus will be set to full-page zoom", vbCritical, "Zoom Mode - " & mjwPDFVersion
        PDFZoomMode = ZOOM_FULLPAGE
    End If

End Property
Property Get PDFGetZoomMode() As Variant
Attribute PDFGetZoomMode.VB_HelpID = 2010

    PDFGetZoomMode = PDFZoomMode

End Property
Property Let PDFUseThumbs(boThumbs As Boolean)
Attribute PDFUseThumbs.VB_HelpID = 2011

    PDFboThumbs = boThumbs

End Property
Property Let PDFUseOutlines(boOutlines As Boolean)
Attribute PDFUseOutlines.VB_HelpID = 2012

    PDFboOutlines = boOutlines

End Property
Property Let PDFSetLayoutMode(pLayoutMode As PDFLayoutMd)
Attribute PDFSetLayoutMode.VB_HelpID = 2013

    If pLayoutMode = LAYOUT_SINGLE Or pLayoutMode = LAYOUT_CONTINOUS Or _
        pLayoutMode = LAYOUT_TWO Or pLayoutMode = LAYOUT_DEFAULT Then
            PDFLayoutMode = pLayoutMode
    Else
        MsgBox "Layout incorrect : " & pLayoutMode & "." & _
                   vbNewLine & _
                   "Layout will be set to simple single page.", vbCritical, "Layout Mode - " & mjwPDFVersion
        PDFLayoutMode = LAYOUT_SINGLE
    End If

End Property
Property Get PDFGetLayoutMode() As Variant
Attribute PDFGetLayoutMode.VB_HelpID = 2014

    PDFGetLayoutMode = PDFLayoutMode

End Property
Property Let PDFSetUnit(str_Unite As PDFUnitStr)
Attribute PDFSetUnit.VB_HelpID = 2015

    Select Case str_Unite
        Case UNIT_PT
            in_Ech = 1
        Case UNIT_MM
            in_Ech = 72 / 25.4
        Case UNIT_CM
            in_Ech = 72 / 2.54
        Case Else
            MsgBox "Incorrect Unit of Measure : " & str_Unite & "." & _
                   vbNewLine & _
                   "Using centimeter ", vbCritical, "Error in measurement unit - " & mjwPDFVersion
            in_Ech = 72 / 2.54
    End Select

End Property
Property Get PDFGetUnit() As String
Attribute PDFGetUnit.VB_HelpID = 2016

    Select Case in_Ech
        Case 1
            PDFGetUnit = "pt"
        Case 72 / 25.4
            PDFGetUnit = "mm"
        Case 72 / 2.54
            PDFGetUnit = "cm"
    End Select

End Property
Property Let PDFOrientation(str_Orientation As PDFOrientationStr)
Attribute PDFOrientation.VB_HelpID = 2017

    Dim tmp_PDFCanvasWidth As Integer
    Dim tmp_PDFCanvasHeight As Integer

    ReDim Preserve PDFCanvasWidth(1 To in_Canvas)
    ReDim Preserve PDFCanvasHeight(1 To in_Canvas)
    ReDim Preserve PDFCanvasOrientation(1 To in_Canvas)

    tmp_PDFCanvasWidth = PDFCanvasWidth(in_Canvas)
    tmp_PDFCanvasHeight = PDFCanvasHeight(in_Canvas)

    Select Case str_Orientation
        Case ORIENT_PORTRAIT
            PDFCanvasWidth(in_Canvas) = tmp_PDFCanvasWidth
            PDFCanvasHeight(in_Canvas) = tmp_PDFCanvasHeight
            PDFCanvasOrientation(in_Canvas) = "p"
        Case ORIENT_PAYSAGE
            PDFCanvasWidth(in_Canvas) = tmp_PDFCanvasHeight
            PDFCanvasHeight(in_Canvas) = tmp_PDFCanvasWidth
            PDFCanvasOrientation(in_Canvas) = "l"
        Case Else
            MsgBox "Orientation set incorrectly: " & str_Orientation & "." & _
                   vbNewLine & _
                   "Orientation set to portrait.", vbCritical, "Error in orientation - " & mjwPDFVersion
            PDFCanvasWidth(in_Canvas) = tmp_PDFCanvasWidth
            PDFCanvasHeight(in_Canvas) = tmp_PDFCanvasHeight
            PDFCanvasOrientation(in_Canvas) = "p"
    End Select

    ReDim Preserve PDFCanvasWidth(1 To in_Canvas)
    ReDim Preserve PDFCanvasHeight(1 To in_Canvas)
    ReDim Preserve PDFCanvasOrientation(1 To in_Canvas)

End Property
0
Comment
Question by:BradleyCleveland
  • 2
  • 2
4 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 33675397
Here's a simple "name" property that just stores a value in a private string variable, of a class in VB6 and the corresponding code in VB.Net
VB:

Private name_ As String

Public Property Let Name(Value As String)

    name_ = Value

End Property

Public Property Get Name()

    Name = name_

End Property







Vb.Net:

Public Class MyVbClass

    Private name_ As String

    Public Property Name As String

        Get

            Return name_

        End Get

        Set(ByVal value As String)

            name_ = value

        End Set

    End Property

End Class

Open in new window

0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 150 total points
ID: 33675473
Assuming this is a class, the let and get is like your setters and getters
simplest way is like you would do a procedure and function in vb



so  Property Let PDFSetZoomMode(pZoomMode As PDFZoomMd)
would be

public sub SetPDFSetZoomMode(byval pZoomMode As PDFZoomMd)

end sub


and Property Get PDFGetZoomMode() would be a function since you want to return a value

public function FetPDFGetZoomMode() as PDFZoomMd
    GetPDFGetZoomMode = PDFZoomMode
end function


but with this the variables should be defined at class level
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 350 total points
ID: 33675545
They are getters and setters, but you wouldn't necessarily write them as subs/functions (unless they make more sense as methods rather than properties).
Public Class MyVbClass

    Public Property PDFSetZoomMode As PDFZoomMd

        Get

            Return PDFZoomMode

        End Get

        Set(ByVal pZoomMode As PDFZoomMd)

            If pZoomMode = ZOOM_FULLPAGE Or pZoomMode = ZOOM_FULLWIDTH Or _

        pZoomMode = ZOOM_REAL Or pZoomMode = ZOOM_DEFAULT Or _

        (IsNumeric(pZoomMode) And (pZoomMode <> ZOOM_FULLPAGE Or _

                                    pZoomMode <> ZOOM_FULLWIDTH Or _

                                    pZoomMode <> ZOOM_REAL Or _

                                    pZoomMode <> ZOOM_DEFAULT)) Then

                If IsNumeric(pZoomMode) Then

                    PDFZoomMode = Int(pZoomMode)

                Else

                    PDFZoomMode = pZoomMode

                End If

            Else

                MsgBox("Incorrect Zoom Mode : " & pZoomMode & "." & _

                           vbNewLine & _

                           "Focus will be set to full-page zoom", vbCritical, "Zoom Mode - " & mjwPDFVersion)

                PDFZoomMode = ZOOM_FULLPAGE

            End If

        End Set

    End Property

    Public WriteOnly Property PDFUseThumgs As Boolean

        Set(ByVal value As Boolean)

            PDFboThumbs = value

        End Set

    End Property

End Class

Open in new window

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33675580
I know, I was just trying to explain in the simplest of forms as a gentle introduction. Trying to explain how existing knowledge can still be useful as a starting place to convert code.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now