VB Migration Partner

KNOWLEDGE BASE - Forms and controls


Previous | Index | Next 

[HOWTO] Change the value of a given property of all controls of specified type or name

VB Migration Partner allows you to “massively” assign the design-time value of a given property to multiple controls, on a given form or all forms in the VB6 project. You can select the affected controls by their type or their name, in both cases using a regular expression. The pragma that does this magic is ChangeProperty, which takes the following four arguments: the property name, the new property value, a regex that identifies the control type (all controls if omitted), and a regex that identifies affected controls by their name (any name if omitted). Here are a few examples:

   '## Rem all command buttons in current form  whose name begins with "cmd" must be 400 twips high
   '## ChangeProperty Height, 400, "VB\.CommandButton", "cmd.+"    '## Rem reset the Text property of all TextBox controls in all forms    '## project:ChangeProperty Text, "", "VB\.TextBox”

The name of controls that belong to a control array include the index between parenthesis:

   '## Rem reset the Text property for all the elements of the "txtFields" control array
   '## ChangeProperty Text, "", "VB\.TextBox", "txtFields\(\d+\)"

You can also perform math operations on the current property value, by prefixing the newvalue argument with the +, -, *, /, \ symbols:

   '## Rem expand the width of all command  buttons in current form by 200 twips
   '## ChangeProperty Width, +200, "VB\.CommandButton"

   '## Rem ensure that all textboxes on current form are multilined and double their height
   '## ChangeProperty Height, *2, "VB\.TextBox"

The second argument can be preceded by the “=” symbol, which allows you to set a negative value for a numeric property or to assign a string property that begins with a math symbol:

   '## Rem set the ListIndex property to -1 for all ListBox controls
   '## ChangeProperty ListIndex, =-1, "VB\.ListBox”

   '## Rem set the Caption property to "+1" for controls named "lblIncr" or "cmdIncr"
   '## project:ChangeProperty Caption, "=+1", , "(lblIncr|cmdIncr)"
Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers