BYTEINSIGHT
GAPVelocity AI Studio helps you move from outdated tech stacks to the latest desktop, web, and cloud platforms—smarter, faster, and with less risk.
Choose a platform to see migration options:
Our comprehensive approach to application modernization, from assessment to production deployment.
Transformation Services
Not Sure Where to Start?
The #If #EndIf directives are evaluated by the VB6 AI Migrator preprocessing engine during the preliminary stage of the upgrade process. The current compiler-variable values are taken into consideration to figure out which blocks of code are active and which are inactive. The active blocks are upgraded to .NET while the inactive ones are copied unchanged to the upgraded code and preceded by the 1035 EWI.
Often times conditional compilation directives might be missing and not all code paths will be expressed. Conditional compilation constants can be defined in three different ways in VB6:
| How Set | Scope |
| Project Properties dialog box | Public to all modules in the project |
| Command line | Public to all modules in the project |
| #Const statement in code | Private to the module in which they are declared |
Knowing the scope of these constants can help when modifying the code to correct this EWI.
Special care should be taken when reviewing conditionally compiled code. Locally declared variables have no effect and are not used for evaluation of conditional compilation directives, such as in Example #2.
#Const ShowMessage = -1 'True
PublicSub ConditionalCompilation()
'ShowMessage is True
#If ShowMessage Then
MsgBox "It will show this message!"
#Else
MsgBox "This text will not show!"
#EndIf
EndSub
PublicSub ImproperConditionalCompilation()
Dim show AsBoolean
Set show = True
' show is a local variable, and is not
' used for conditional compilation
#If show Then
MsgBox "This text will not show!"
#Else
'This message box is shown.
MsgBox "It will show this message!"
#EndIf
EndSub
#Const ShowMessage = -1'True
PublicSub ConditionalCompilation()
#If ShowMessage Then
MessageBox.Show("It will show this message!", Application.ProductName)
#Else
'UPGRADE_TODO: (1035) #If #EndIf block was not upgraded because the expression Else did not evaluate to True or was not evaluated.
MsgBox "This text will not show!"
#EndIf
EndSub
PublicSub ImproperConditionalCompilation()
Dim show AsBoolean = True
#If show Then
'UPGRADE_TODO: (1035) #If #EndIf block was not upgraded because the expression show did not evaluate to True or was not evaluated.
MsgBox "This text will not show!"
#Else
MessageBox.Show("It will show this message!", Application.ProductName)
#EndIf
EndSub
#Const ShowMessage = -1'True
PublicSub ConditionalCompilation()
#If ShowMessage Then
MessageBox.Show("It will show this message!", Application.ProductName)
#Else
MessageBox.Show("This text will not show!", Application.ProductName)
#EndIf
EndSub
PublicSub ImproperConditionalCompilation()
Dim show AsBoolean = True
#If show Then
MessageBox.Show("This text will not show!", Application.ProductName)
#Else
MessageBox.Show("It will show this message!", Application.ProductName)
#EndIf
EndSub
#undef ShowMessage
staticpublicvoid ConditionalCompilation()
{
#if ShowMessage
MessageBox.Show("It will show this message!", Application.ProductName);
#else
//UPGRADE_TODO: (1035) #If #EndIf block was not upgraded because the expression Else did not evaluate to True or was not evaluated.
MsgBox "This text will not show!"
#endif
}
staticpublicvoid ImproperConditionalCompilation()
{
bool show = true;
#if show
//UPGRADE_TODO: (1035) #If #EndIf block was not upgraded because the expression show did not evaluate to True or was not evaluated.
MsgBox "This text will not show!"
#else
MessageBox.Show("It will show this message!", Application.ProductName);
#endif
}
#define ShowMessage
staticpublicvoid ConditionalCompilation()
{
#if ShowMessage
MessageBox.Show("It will show this message!", Application.ProductName);
#else
MessageBox.Show("This text will not show!");
#endif
}
staticpublicvoid ImproperConditionalCompilation()
{
bool show = true;
#if show
MessageBox.Show("This text will not show!");
#else
MessageBox.Show("It will show this message!", Application.ProductName);
#endif
}