All the options are in the vb2py.ini file located in the main vb2py folder.
IgnoreLabels
UseNewStyleClasses
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
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 |
---|---|
|
|
Be careful when switching to Tab to set the IndentAmount, or you will end up with four tabs!
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
Other values are allowed.
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
Other values are allowed.
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
Other values are allowed.
VB | Python |
---|---|
|
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.
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.
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.
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 |
---|---|
|
|
An example with No.
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
If the value used is not "__" then the data will not be hidden as far as Python is concerned.
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
Setting the option to Yes is safe but doesn't always look good in the code.
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
When the option is Yes docstrings will be created.
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
When the option is No you wont get any output if there is an error.
VB | Python |
---|---|
|
|
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
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 |
---|---|
|
|
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 |
---|---|
|
|
Compare this with,
VB | Python |
---|---|
|
|
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
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 |
---|---|
|
|
Compare this to,
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
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 |
---|---|
|
|
Comapre this to,
VB | Python |
---|---|
|
|
The list of all Labels options is shown in the following table:
[Labels] # Yes or No, ignore labels completely IgnoreLabels = Yes
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 |
---|---|
|
|
Comapre this to,
VB | Python |
---|---|
|
|
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
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 |
---|---|
|
|
Compare this to,
VB | Python |
---|---|
|
|
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 |
---|---|
|
|
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 |
---|---|
|
|
Compare this to,
VB | Python |
---|---|
|
|
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
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 |
---|---|
|
|
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 |
---|---|
|
|
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
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 |
---|---|
|
|
Compare this to,
VB | Python |
---|---|
|
|