Switch Assignment

Top  Previous  Next

 VS   VB6   VBA 

The Switch Assignment feature allows you to swap the left and right sides of an assignment statement of one or more selected lines in a source code file. This is useful, for example, when you have to assign the values to a set of controls:

TextBoxFirstName.Text = firstName

TextBoxLastName.Text = lastName

TextBoxEMail.Text = eMail

and in another part of your code you have to do the opposite assignment:

firstName = TextBoxFirstName.Text

lastName = TextBoxLastName.Text

eMail = TextBoxEMail.Text

In this case the second block of code could be generated copying and pasting the first block, selecting the pasted block and applying this feature.

MZ-Tools offers the following ways to switch the sides of an assignment:

  • The MZ-Tools | Other Utilities | Switch Assignment menu.
  • The Switch Assignment menu entry on the context menu of a code window.
  • The Switch Assignment button on the MZ-Tools - Other Utilities toolbar.
  • In Visual Studio 2015 and higher, the keyboard shortcut associated with the MZTools.SwitchAssignment command.
  • In Visual Studio 2013 and lower, the keyboard shortcut associated with the MZTools8.SwitchAssignment command.
  • In VB6 / VBA, the keyboard shortcut associated with the Switch Assignment feature.

See Also:

Keyboard Shortcuts Options