# List Of Options

All the options are in the `vb2py.ini` file located in the main `vb2py` folder.

General

> IndentCharacter

> IndentAmount

> AttentionMarker

> WarnAboutUnrenderedCode

> LoadUserPlugins

> LoggingLevel

> DumpFormData

> RespectPrivateStatus

> PrivateDataPrefix

> AlwaysUseRawStringLiterals

> TryToExtractDocStrings

> ReportPartialConversion

> IncludeDebugCode

Functions

> ReturnVariableName

> PreInitializeReturnVariable

Select

> EvaluateVariable

> SelectVariablePrefix

> UseNumericIndex

Labels

> IgnoreLabels

With

> With EvaluateVariable

> WithVariablePrefix

> With UseNumericIndex

Properties

> LetSetVariablePrefix

> GetVariablePrefix

Classes

> UseNewStyleClasses

# General

The list of all `General` options is shown in the following table:

    [General]
    # Space or Tab
    IndentCharacter = Space
    # Number of spaces/tabs
    IndentAmount = 4
    # Marker to use when code needs user attention
    AttentionMarker = VB2PY
    # Yes or No
    WarnAboutUnrenderedCode = Yes
    # Yes or No, whether to use user plugins or not. If No, system plugins will still work
    LoadUserPlugins = No
    # Default logging level, 0 is nothing
    LoggingLevel = 0
    # Yes or No, whether to dump form data to screen - Yes seems to crash the GUI!
    DumpFormData = No
    # Yes or No, whether the full VB parser is used to convert code
    UseFullParser = Yes
    # Yes or No, whether to respect Private status of variables
    RespectPrivateStatus = Yes
    # Prefix to use to tag data as private (Python normally uses __ but VB convention is m_)
    PrivateDataPrefix = __
    # Yes or No, whether to use raw strings for all literals - very safe but not necessarily good looking!
    AlwaysUseRawStringLiterals = No
    # Yes or No, whether to try to automatically extract docstrings from the code
    TryToExtractDocStrings = Yes
    # Yes or No, whether to return a partially converted file when an error is found
    ReportPartialConversion = Yes
    # Yes or No, whether to include debug code in the converted application
    IncludeDebugCode = No

## IndentCharacter

Syntax: `IndentCharacter = Space | Tab`

    # Space or Tab
    IndentCharacter = Space

Sets the indentation character as a Space or a Tab. The number of indent characters is set by the IndentAmount.

The default is a space.

VB | Python
--- | ---
    ' VB2PY-Set: General.IndentCharacter = Space
        If a = 10 Then
                b = 1
        Else
                b = 2
        End If
    ' VB2PY-Unset: General.IndentCharacter
        if a == 10:
            b = 1
        else:
            b = 2

Be careful when switching to `Tab` to set the IndentAmount, or you will end up with four tabs!

VB | Python
--- | ---
    ' VB2PY-Set: General.IndentCharacter = Tab
        If a = 10 Then
                b = 1
        Else
                b = 2
        End If
    ' VB2PY-Unset: General.IndentCharacter
        if a == 10:
            b = 1
        else:
            b = 2

## IndentAmount

Syntax: `IndentAmount = <integer>`

    # Space or Tab
    IndentAmount = 4

Sets the number of IndentCharacter 's to be used to indent code blocks.

The default is 4.

VB | Python
--- | ---
    ' VB2PY-Set: General.IndentAmount = 4
        If a = 10 Then
                b = 1
        Else
                b = 2
        End If
    ' VB2PY-Unset: General.IndentAmount
        if a == 10:
            b = 1
        else:
            b = 2

Other values are allowed.

VB | Python
--- | ---
    ' VB2PY-Set: General.IndentAmount = 8
        If a = 10 Then
                b = 1
        Else
                b = 2
        End If
    ' VB2PY-Unset: General.IndentAmount
        if a == 10:
            b = 1
        else:
            b = 2

## AttentionMarker

Syntax: `AttentionMarker = <string>`

    # Marker to use when code needs user attention
    AttentionMarker = VB2PY

Sets the marker to use in comments when highlighting part of the converted code that needs attention.

The default is VB2PY.

VB | Python
--- | ---
    ' VB2PY-Set: General.AttentionMarker = VB2PY
        On Error Goto 0
    ' VB2PY-Unset: General.AttentionMarker
        # VB2PY (UntranslatedCode) On Error Goto 0

Other values are allowed.

VB | Python
--- | ---
    ' VB2PY-Set: General.AttentionMarker = TODO
        On Error Goto 0
    ' VB2PY-Unset: General.AttentionMarker
        # TODO (UntranslatedCode) On Error Goto 0

## WarnAboutUnrenderedCode

Syntax: `WarnAboutUnrenderedCode = Yes | No`

    # Yes or No
    WarnAboutUnrenderedCode = Yes

Determined whether an AttentionMarker is inserted in the Python code to highligh VB code which has not been rendered.

The default is Yes.

VB | Python
--- | ---
    ' VB2PY-Set: General.WarnAboutUnrenderedCode = Yes
        On Error Goto 0
    ' VB2PY-Unset: General.WarnAboutUnrenderedCode
        # VB2PY (UntranslatedCode) On Error Goto 0

Other values are allowed.

VB | Python
--- | ---
    ' VB2PY-Set: General.WarnAboutUnrenderedCode = No
        On Error Goto 0
    ' VB2PY-Unset: General.WarnAboutUnrenderedCode

## LoadUserPlugins

Syntax: `LoadUserPlugins = Yes | No`

    # Yes or No, whether to use user plugins or not. If No, system plugins will still work
    LoadUserPlugins = No

Determines whether user plug-ins are loaded and executed during the normal code conversion process. User plug-ins are kept in the `extensions` folder of the `vb2py` directory. System plug-ins are also located in this folder but are not affected by the value of this setting.

## LoggingLevel

Syntax: `LoggingLevel = <integer>`

    # Default logging level, 0 is nothing
    LoggingLevel = 0

Sets the default logging level to use during the code conversion. If this is set to 0 then no logging messages will be output. The logging levels are defined in the standard Python logging module.

## DumpFormData

Syntax: `DumpFormData = Yes | No`

    # Yes or No, whether to dump form data to screen - Yes seems to crash the GUI!
    DumpFormData = No

If this is set to `Yes` then the form classes will be dumped to the screen during form conversion. This may be useful if there is a problem during the conversion process.

The default is No.

## RespectPrivateStatus

Syntax: `RespectPrivateStatus = Yes | No`

    # Yes or No, whether to respect Private status of variables
    RespectPrivateStatus = Yes

If this variable is set to `Yes` then variables, subroutines and functions in VB which are either explicitely or implicitely `Private` will have their Python names converted to have a PrivateDataPrefix. Setting this variable to `No` will ignore the `Private` status of all variables.

The default is Yes.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.RespectPrivateStatus = Yes
    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: General.RespectPrivateStatus
    class MyClass(Object):
            """"""

            Name = String()
            Age = Single()
            __ID = Long()

            def checkAge(self):
                if self.Age == 0:
                    self.Age = 1

            def __setUp(self):
                self.__ID = Rnd()
                if self.__ID == 0:
                    self.__setUp()

An example with No.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.RespectPrivateStatus = No
    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: General.RespectPrivateStatus
    class MyClass(Object):
            """"""

            Name = String()
            Age = Single()
            ID = Long()

            def checkAge(self):
                if self.Age == 0:
                    self.Age = 1

            def setUp(self):
                self.ID = Rnd()
                if self.ID == 0:
                    self.setUp()

## PrivateDataPrefix

Syntax: `PrivateDataPrefix = <string>`

    # Prefix to use to tag data as private (Python normally uses __ but VB convention is m_)
    PrivateDataPrefix = __

If RespectPrivateStatus is set to `Yes` then variables, subroutines and functions in VB which are either explicitely or implicitely `Private` will have their Python names converted to have a prefix and this setting determines what that prefix will be.

The default is ___.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.PrivateDataPrefix = prv
    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: General.PrivateDataPrefix
    class MyClass(Object):
            """"""

            Name = String()
            Age = Single()
            prvID = Long()

            def checkAge(self):
                if self.Age == 0:
                    self.Age = 1

            def prvsetUp(self):
                self.prvID = Rnd()
                if self.prvID == 0:
                    self.prvsetUp()

If the value used is not "__" then the data will not be hidden as far as Python is concerned.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.PrivateDataPrefix = m_
    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: General.PrivateDataPrefix
    class MyClass(Object):
            """"""

            Name = String()
            Age = Single()
            m_ID = Long()

            def checkAge(self):
                if self.Age == 0:
                    self.Age = 1

            def m_setUp(self):
                self.m_ID = Rnd()
                if self.m_ID == 0:
                    self.m_setUp()

## AlwaysUseRawStringLiterals

Syntax: `AlwaysUseRawStringLiterals = Yes | No`

    # Yes or No, whether to use raw strings for all literals - very safe but not necessarily good looking!
    AlwaysUseRawStringLiterals = No

By default, all VB strings are just converted to Python strings. However, if the VB string contains the backslash character then it is quite likely that the Python version will not be the same since Python will interpret the backslash as a control character. Setting the `AlwaysUseRawStringLiterals` option to `Yes` will cause all VB strings to be converted to raw Python strings (r"string"), which will prevent such problems.

The default is No.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.AlwaysUseRawStringLiterals = No
    myString = "a\path\name"
    ' VB2PY-Unset: General.AlwaysUseRawStringLiterals
        # VB2PY (ParserError) Parsing error: 0, 'myString = "a\path\name"'
        # VB2PY (ParserStop) Conversion of VB code halted

Setting the option to `Yes` is safe but doesn't always look good in the code.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.AlwaysUseRawStringLiterals = Yes
    myString = "a\path\name"
    ' VB2PY-Unset: General.AlwaysUseRawStringLiterals
        # VB2PY (ParserError) Parsing error: 0, 'myString = "a\path\name"'
        # VB2PY (ParserStop) Conversion of VB code halted

## TryToExtractDocStrings

Syntax: `TryToExtractDocStrings = Yes | No`

    # Yes or No, whether to try to automatically extract docstrings from the code
    TryToExtractDocStrings = Yes

If `TryToExtractDocStrings` is set then any contiguous block of comment lines found at the start of a module are interpretted as a docstring and added to the class definition. The docstring terminates with the first non-comment line.

The default is `No`.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.TryToExtractDocStrings = No
        ' This is the documentation for the module
        ' This line is also documentation
        ' So is this one
        ' And this is the last

    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: General.TryToExtractDocStrings
        Name = String()
        Age = Single()
        ID = Long()

        def checkAge():
            global Age
            if Age == 0:
                Age = 1

        def setUp():
            global ID
            ID = Rnd()
            if ID == 0:
                setUp()

        # This is the documentation for the module
        # This line is also documentation
        # So is this one
        # And this is the last
        #

When the option is `Yes` docstrings will be created.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: General.TryToExtractDocStrings = Yes
        ' This is the documentation for the module
        ' This line is also documentation
        ' So is this one
        ' And this is the last

    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: General.TryToExtractDocStrings
        """ This is the documentation for the module
         This line is also documentation
         So is this one
         And this is the last

        """

        Name = String()
        Age = Single()
        ID = Long()

        def checkAge():
            global Age
            if Age == 0:
                Age = 1

        def setUp():
            global ID
            ID = Rnd()
            if ID == 0:
                setUp()

## ReportPartialConversion

Syntax: `ReportPartialConversion = Yes | No`

    # Yes or No, whether to return a partially converted file when an error is found
    ReportPartialConversion = Yes

This option is used to determine what happens when the conversion fails for some reason. If the option is set to `Yes` then the conversion will return as much code as it can. If the option is set to `No` then the conversion will just fail and return nothing at all.

The default is `Yes`.

VB | Python
--- | ---
     ' VB2PY-Set: General.ReportPartialConversion = Yes
         a = 10
         b = 20
         c = 30
         something that wont convert
         d = 40
         e = 50
    ' VB2PY-Unset: General.ReportPartialConversion
        a = 10
        b = 20
        c = 30
        # VB2PY (ParserError) Parsing error: 0, 'something that wont convert'
        # VB2PY (ParserStop) Conversion of VB code halted

When the option is `No` you wont get any output if there is an error.

VB | Python
--- | ---
     ' VB2PY-Set: General.ReportPartialConversion = No
         a = 10
         b = 20
         c = 30
         something that wont convert
         d = 40
         e = 50
    ' VB2PY-Unset: General.ReportPartialConversion
        a = 10
        b = 20
        c = 30
        # VB2PY (ParserError) Parsing error: 0, 'something that wont convert'
        # VB2PY (ParserStop) Conversion of VB code halted

## IncludeDebugCode

Syntax: `IncludeDebugCode = Yes | No`

    # Yes or No, whether to include debug code in the converted application
    IncludeDebugCode = No

This option is used to determine whether debug code is included in the converted application. If the option is `Yes` then a `from vbdebug import *` will be inserted at the top of each module. `vbdebug` includes code to access the logger and is required if you need to view the output from `Debug.Print` statements.

The default is `No`.

VB | Python
--- | ---
     ' VB2PY-Set: General.IncludeDebugCode = No
         a = 10
         b = 20
         c = 30
    ' VB2PY-Unset: General.IncludeDebugCode
        a = 10
        b = 20
        c = 30

When the option is `Yes` you get the extra `import` statement

VB | Python
--- | ---
     ' VB2PY-Set: General.IncludeDebugCode = Yes
         a = 10
         b = 20
         c = 30
    ' VB2PY-Unset: General.IncludeDebugCode
        a = 10
        b = 20
        c = 30

# Functions

The list of all `Function` options is shown in the following table:

    [Functions]
    # Name of variable used in Functions
    ReturnVariableName = _ret
    # Yes or No, leave at Yes unless good reasons!
    PreInitializeReturnVariable = Yes

## ReturnVariableName

Syntax: `ReturnVariableName = <string>`

    # Name of variable used in Functions
    ReturnVariableName = _ret

This option allows the return variable name to be specified. No checking is done to ensure that the name does not clash with local or global variables, so care should be taken when selecting a suitable name.

VB | Python
--- | ---
    Dim moduleGlobal1, moduleGlobal2

    ' VB2PY-GlobalSet: Functions.ReturnVariableName = _MyFunc
    Function MyFunc(X, Optional Y, Optional Z=20)
        Dim subLocal
        subLocal = X + Y + Z + moduleGlobal
        moduleGlobal2 = moduleGlobal2 + 1
        MyFunc = subLocal*10
    End Function
    ' VB2PY-Unset: Functions.ReturnVariableName

    a = MyFunc(1, 2)
    a = MyFunc(1, Z:=10)
        moduleGlobal1 = Variant()
        moduleGlobal2 = Variant()

        def MyFunc(X, Y=VBMissingArgument, Z=20):
            global moduleGlobal2
            _MyFunc = None
            subLocal = X + Y + Z + moduleGlobal
            moduleGlobal2 = moduleGlobal2 + 1
            _MyFunc = subLocal * 10
            return _MyFunc

        a = MyFunc(1, 2)
        a = MyFunc(1, Z= 10)

## PreInitializeReturnVariable

Syntax: `PreInitializeReturnVariable = Yes | No`

    # Yes or No, leave at Yes unless good reasons!
    PreInitializeReturnVariable = Yes

By default the return variable is initialized to `None` at the start of the function so that an error does not occur in the event that the function returns before the return variable has been assigned to. This option allows this initialization step to be omitted and is safe as long as all return paths from the function include an explicit assignment to the return value variable.

VB | Python
--- | ---
    Dim moduleGlobal1, moduleGlobal2

    ' VB2PY-GlobalSet: Functions.PreInitializeReturnVariable = Yes
    Function MyFunc(X, Optional Y, Optional Z=20)
        Dim subLocal
        subLocal = X + Y + Z + moduleGlobal
        moduleGlobal2 = moduleGlobal2 + 1
        MyFunc = subLocal*10
    End Function
    ' VB2PY-Unset: Functions.PreInitializeReturnVariable

    a = MyFunc(1, 2)
    a = MyFunc(1, Z:=10)
        moduleGlobal1 = Variant()
        moduleGlobal2 = Variant()

        def MyFunc(X, Y=VBMissingArgument, Z=20):
            global moduleGlobal2
            _ret = None
            subLocal = X + Y + Z + moduleGlobal
            moduleGlobal2 = moduleGlobal2 + 1
            _ret = subLocal * 10
            return _ret

        a = MyFunc(1, 2)
        a = MyFunc(1, Z= 10)

Compare this with,

VB | Python
--- | ---
    Dim moduleGlobal1, moduleGlobal2

    ' VB2PY-GlobalSet: Functions.PreInitializeReturnVariable = No
    Function MyFunc(X, Optional Y, Optional Z=20)
        Dim subLocal
        subLocal = X + Y + Z + moduleGlobal
        moduleGlobal2 = moduleGlobal2 + 1
        MyFunc = subLocal*10
    End Function
    ' VB2PY-Unset: Functions.PreInitializeReturnVariable

    a = MyFunc(1, 2)
    a = MyFunc(1, Z:=10)
        moduleGlobal1 = Variant()
        moduleGlobal2 = Variant()

        def MyFunc(X, Y=VBMissingArgument, Z=20):
            global moduleGlobal2
            subLocal = X + Y + Z + moduleGlobal
            moduleGlobal2 = moduleGlobal2 + 1
            _ret = subLocal * 10
            return _ret

        a = MyFunc(1, 2)
        a = MyFunc(1, Z= 10)

# Select

The list of all `Select` options is shown in the following table:

    [Select]
    # Once or EachTime, how many times to evaluate the case variable
    EvaluateVariable = Once
    # Name of select variable (only used if EvaluateVariable is Once)
    SelectVariablePrefix = _select
    # Yes or No, use numeric index on select variable (needed if you every have nested Selects and EvaluateVariable = Once)
    UseNumericIndex = Yes

## EvaluateVariable

Syntax: `EvaluateVariable = Yes | No`

    # Once or EachTime, how many times to evaluate the case variable
    EvaluateVariable = Once

The default behaviour when converting a `Select` is to evaluate the select expression once at the start of the block. By setting this option to `EachTime` you can force the expression to be evaluated for each `if/elif` statement. This generally looks cleaner but can lead to undesired side effects or slow run times depending on how expensive the expression is to calculate.

VB | Python
--- | ---
    ' VB2PY-Set: Select.EvaluateVariable = Once
    Select Case Value
        Case 1
            DoOne
        Case 2
            DoTwo
        Case 3, 4
            DoThreeOrFour
        Case 5 To 10
            DoFiveToTen
        Case Else
            DoElse
    End Select
    ' VB2PY-Unset: Select.EvaluateVariable
        _select0 = Value
        if (_select0 == 1):
            DoOne()
        elif (_select0 == 2):
            DoTwo()
        elif (_select0 == 3) or (_select0 == 4):
            DoThreeOrFour()
        elif (5 <= _select0 <= 10):
            DoFiveToTen()
        else:
            DoElse()

Compare this to,

VB | Python
--- | ---
    ' VB2PY-Set: Select.EvaluateVariable = EachTime
    Select Case Value
        Case 1
            DoOne
        Case 2
            DoTwo
        Case 3, 4
            DoThreeOrFour
        Case 5 To 10
            DoFiveToTen
        Case Else
            DoElse
    End Select
    ' VB2PY-Unset: Select.EvaluateVariable
        if (Value == 1):
            DoOne()
        elif (Value == 2):
            DoTwo()
        elif (Value == 3) or (Value == 4):
            DoThreeOrFour()
        elif (5 <= Value <= 10):
            DoFiveToTen()
        else:
            DoElse()

## SelectVariablePrefix

Syntax: `SelectVariablePrefix = <string>`

    # Name of select variable (only used if EvaluateVariable is Once)
    SelectVariablePrefix = _select

When EvaluateVariable is set to `Once`, this option determines the prefix used to name the variable used in the select. If UseNumericIndex is set to `No` then this option sets the variable name used, otherwise this is the prefix and the final variable will also include a unique ID number.

VB | Python
--- | ---
    ' VB2PY-Set: Select.SelectVariablePrefix = selectVariable
    Select Case Value
        Case 1
            DoOne
        Case 2
            DoTwo
        Case 3, 4
            DoThreeOrFour
        Case 5 To 10
            DoFiveToTen
        Case Else
            DoElse
    End Select
    ' VB2PY-Unset: Select.SelectVariablePrefix
        selectVariable2 = Value
        if (selectVariable2 == 1):
            DoOne()
        elif (selectVariable2 == 2):
            DoTwo()
        elif (selectVariable2 == 3) or (selectVariable2 == 4):
            DoThreeOrFour()
        elif (5 <= selectVariable2 <= 10):
            DoFiveToTen()
        else:
            DoElse()

## UseNumericIndex

Syntax: `UseNumericIndex = Yes | No`

    # Yes or No, use numeric index on select variable (needed if you every have nested Selects and EvaluateVariable = Once)
    UseNumericIndex = Yes

When EvaluateVariable is set to `Once`, this option determines whether a unique ID number is appended to the SelectVariablePrefix to determine the variable name used to hold the select expression. If used, the index is incremented for each `select` constuct found. This option is always required to be `Yes` where the code includes nested `Select` blocks and EvaluateVariable is set to `Once`. If neither of these conditions applies then it is safe to set this to `No`

VB | Python
--- | ---
    ' VB2PY-Set: Select.UseNumericIndex = Yes
    Select Case Value
        Case 1
            DoOne
        Case 2
            DoTwo
        Case 3, 4
            DoThreeOrFour
        Case 5 To 10
            DoFiveToTen
        Case Else
            DoElse
    End Select
    ' VB2PY-Unset: Select.UseNumericIndex
        _select3 = Value
        if (_select3 == 1):
            DoOne()
        elif (_select3 == 2):
            DoTwo()
        elif (_select3 == 3) or (_select3 == 4):
            DoThreeOrFour()
        elif (5 <= _select3 <= 10):
            DoFiveToTen()
        else:
            DoElse()

Comapre this to,

VB | Python
--- | ---
    ' VB2PY-Set: Select.UseNumericIndex = No
    Select Case Value
        Case 1
            DoOne
        Case 2
            DoTwo
        Case 3, 4
            DoThreeOrFour
        Case 5 To 10
            DoFiveToTen
        Case Else
            DoElse
    End Select
    ' VB2PY-Unset: Select.UseNumericIndex
        _select = Value
        if (_select == 1):
            DoOne()
        elif (_select == 2):
            DoTwo()
        elif (_select == 3) or (_select == 4):
            DoThreeOrFour()
        elif (5 <= _select <= 10):
            DoFiveToTen()
        else:
            DoElse()

# Labels

The list of all `Labels` options is shown in the following table:

    [Labels]
    # Yes or No, ignore labels completely
    IgnoreLabels = Yes

## IgnoreLabels

Syntax: `IgnoreLabels = Yes | No`

    # Yes or No, ignore labels completely
    IgnoreLabels = Yes

Labels are not supported in vb2Py v0.2. If you have VB code with labels on every line then you will get a huge number of attention markers telling you that the label was not converted. You can silence these warning by setting the `IgnoreLabels` option to `Yes`.

VB | Python
--- | ---
    ' VB2PY-Set: Labels.IgnoreLabels = No
        10: a=1
        20: b=2
        30: c=3
    ' VB2PY-Unset: Labels.IgnoreLabels
        # VB2PY (UntranslatedCode) 10:
        a = 1
        # VB2PY (UntranslatedCode) 20:
        b = 2
        # VB2PY (UntranslatedCode) 30:
        c = 3

Comapre this to,

VB | Python
--- | ---
    ' VB2PY-Set: Labels.IgnoreLabels = Yes
        10: a=1
        20: b=2
        30: c=3
    ' VB2PY-Unset: Labels.IgnoreLabels
        a = 1
        b = 2
        c = 3

# With

The list of all `With` options is shown in the following table:

    [With]
    # Once or EachTime, how many times to evaluate the with variable
    EvaluateVariable = Once
    # Name of with variable (only used if EvaluateVariable is Once)
    WithVariablePrefix = _with
    # Yes or No, use numeric index on with variable (needed if you every have nested Withs and EvaluateVariable = Once)
    UseNumericIndex = Yes

## With EvaluateVariable

Syntax: `EvaluateVariable = Yes | No`

    [With]
    # Once or EachTime, how many times to evaluate the with variable

The default behaviour is to evaluate the `With` object once at the start of the block. By setting this option to `EachTime` you can force the object to be evaluated each time it is required. This generally looks more natural but can lead to undesired side effects or slow run times depending on how expensive [1]_ the object is to calculate.

VB | Python
--- | ---
    ' VB2PY-Set: With.EvaluateVariable = Once
    With MyObject
        .Height = 10
        .Width = .Height * .ScaleFactor
    End With
    ' VB2PY-Unset: With.EvaluateVariable
        _with0 = MyObject
        _with0.Height = 10
        _with0.Width = _with0.Height * _with0.ScaleFactor

Compare this to,

VB | Python
--- | ---
    ' VB2PY-Set: With.EvaluateVariable = EveryTime
    With MyObject
        .Height = 10
        .Width = .Height * .ScaleFactor
    End With
    ' VB2PY-Unset: With.EvaluateVariable
        MyObject.Height = 10
        MyObject.Width = MyObject.Height * MyObject.ScaleFactor

## WithVariablePrefix

Syntax: `WithVariablePrefix = <string>`

    # Name of with variable (only used if EvaluateVariable is Once)
    WithVariablePrefix = _select

When With EvaluateVariable is set to `Once`, this option determines the prefix used to name the variable used in the `With`. If With UseNumericIndex is set to `No` then this option sets the variable name used, otherwise this is the prefix and the final variable will also include a unique ID number.

VB | Python
--- | ---
    ' VB2PY-Set: With.WithVariablePrefix = withVariable
    With MyObject
        .Height = 10
        .Width = .Height * .ScaleFactor
    End With
    ' VB2PY-Unset: With.WithVariablePrefix
        withVariable2 = MyObject
        withVariable2.Height = 10
        withVariable2.Width = withVariable2.Height * withVariable2.ScaleFactor

## With UseNumericIndex

Syntax: `UseNumericIndex = Yes | No`

    # Yes or No, use numeric index on select variable (needed if you every have nested Selects and EvaluateVariable = Once)
    UseNumericIndex = Yes

When With EvaluateVariable is set to `Once`, this option determines whether a unique ID number is appended to the WithVariablePrefix to determine the variable name used to hold the object. If used, the index is incremented for each `With` constuct found. This option is always required to be `Yes` where the code includes nested `With` blocks and With EvaluateVariable is set to `Once`. If neither of these conditions applies then it is safe to set this to `No`

VB | Python
--- | ---
    ' VB2PY-Set: With.UseNumericIndex = No
    With MyObject
        .Height = 10
        .Width = .Height * .ScaleFactor
    End With
    ' VB2PY-Unset: With.UseNumericIndex
        _with = MyObject
        _with.Height = 10
        _with.Width = _with.Height * _with.ScaleFactor

Compare this to,

VB | Python
--- | ---
    ' VB2PY-Set: With.UseNumericIndex = Yes
    With MyObject
        .Height = 10
        .Width = .Height * .ScaleFactor
    End With
    ' VB2PY-Unset: With.UseNumericIndex
        _with4 = MyObject
        _with4.Height = 10
        _with4.Width = _with4.Height * _with4.ScaleFactor

# Properties

The list of all `Property` options is shown in the following table:

    [Properties]
    # Prefix to add to property Let/Set function name
    LetSetVariablePrefix = set
    # Prefix to add to property Get function name
    GetVariablePrefix = get

## LetSetVariablePrefix

Syntax: `LetSetVariablePrefix = <string>`

    # Prefix to add to property Let/Set function name
    LetSetVariablePrefix = set

In class modules where properties are defined, vb2Py creates `get` and `set` methods to access and assign to the property. Since VB uses a syntactic form to distinguish between the getters and setters but Python uses different names with the same syntax there is a need to automatically generate a name for the `get` and `set` methods. The `getter` and `setter` methods are determined by the LetSetVariablePrefix and GetVariablePrefix respectively.

VB | Python
--- | ---
    ' VB2PY-Set: Properties.LetSetVariablePrefix = doSet_
    Dim mName As String
    Dim mAge As Single

    Public Property Let Name(Value)
        mName = Value
    End Property
    '
    Public Property Get Name()
        Name = mName
    End Property

    ' VB2PY-Unset: Properties.LetSetVariablePrefix
        """"""

        mName = String()
        mAge = Single()

        def setName(Value):
            global mName
            mName = Value

        def getName():
            global Name
            _ret = None
            _ret = mName
            return _ret
        Name = property(fset=setName, fget=getName)

## GetVariablePrefix

Syntax: `GetVariablePrefix = <string>`

    # Prefix to add to property Get function name
    GetVariablePrefix = set

In class modules where properties are defined, vb2Py creates `get` and `set` methods to access and assign to the property. Since VB uses a syntactic form to distinguish between the getters and setters but Python uses different names with the same syntax there is a need to automatically generate a name for the `get` and `set` methods. The `getter` and `setter` methods are determined by the LetSetVariablePrefix and GetVariablePrefix respectively.

VB | Python
--- | ---
    ' VB2PY-Set: Properties.GetVariablePrefix = doGet_
    Dim mName As String
    Dim mAge As Single

    Public Property Let Name(Value)
        mName = Value
    End Property
    '
    Public Property Get Name()
        Name = mName
    End Property

    ' VB2PY-Unset: Properties.GetVariablePrefix
        """"""

        mName = String()
        mAge = Single()

        def setName(Value):
            global mName
            mName = Value

        def getName():
            global Name
            _ret = None
            _ret = mName
            return _ret
        Name = property(fset=setName, fget=getName)

# Classes

The list of all `Class` options is shown in the following table:

    [Classes]
    # Yes or No, whether to use new style classes for all classes
    UseNewStyleClasses = Yes

## UseNewStyleClasses

Syntax: `UseNewStyleClasses = Yes | No`

    # Yes or No, whether to use new style classes for all classes
    UseNewStyleClasses = Yes

By default, all classes are created as new style Python classes (inheriting from `Object`). Old style classes can be created by setting the `UseNewStyleClasses` option to `No`.

VB | Python
--- | ---
    ' VB2PY-GlobalSet: Classes.UseNewStyleClasses = Yes
    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: Classes.UseNewStyleClasses
    class MyClass(Object):
            """"""

            Name = String()
            Age = Single()
            __ID = Long()

            def checkAge(self):
                if self.Age == 0:
                    self.Age = 1

            def __setUp(self):
                self.__ID = Rnd()
                if self.__ID == 0:
                    self.__setUp()

Compare this to,

VB | Python
--- | ---
    ' VB2PY-GlobalSet: Classes.UseNewStyleClasses = No
    Public Name As String
    Public Age As Single
    Private ID As Long

    Public Sub checkAge()
        If Age = 0 Then Age = 1
    End Sub
    '
    Private Sub setUp()
        ID = Rnd()
        If ID = 0 Then setUp
    End Sub
    ' VB2PY-Unset: Classes.UseNewStyleClasses
    class MyClass:
            """"""

            Name = String()
            Age = Single()
            __ID = Long()

            def checkAge(self):
                if self.Age == 0:
                    self.Age = 1

            def __setUp(self):
                self.__ID = Rnd()
                if self.__ID == 0:
                    self.__setUp()

# Docutils System Messages

System Message: ERROR/3 (`<string>`, line 845); backlink

Unknown target name: "1".