<variable1> of type Variant is being forced to Scalar.


    The VBUC typing engine is able to infer the correct data type of undefined or Variant-type variables, and assign them the correct data type. In some scenarios, a variant-type variable is upgraded to a scalar value; this type inference is done over the variable usage and context.


    This issue doesn't have any recommendations.

    Sample VB6

    Public Sub ForcedToScalar(b As Boolean)
       Dim v As Variant
       If b Then
         Set v = Form1
         MsgBox v / 3
         Set v = Class1
       End If
       MsgBox v
    End Sub

    Target VB.NET

    PublicSub ForcedToScalar(ByRef b AsBoolean)
       Dim Class1 As Form1
       Dim v As Form1
       If b Then
           v = Me
          'UPGRADE_WARNING: (1068) v of type Form1 is being forced to Double.
          MessageBox.Show(CStr(CDbl(v) / 3), Application.ProductName)
          v = Class1
       'UPGRADE_WARNING: (1068) v of type Form1 is being forced to String.
       MessageBox.Show(CStr(v), Application.ProductName)

    Target C#

    publicvoid ForcedToScalar( bool b)
       Form1 Class1 = null;
       Form1 v = null;
       if (b)
          v = Form1.DefInstance;
          //UPGRADE_WARNING: (1068) v of type Form1 is being forced to double.
          MessageBox.Show((((double) v) / 3).ToString(), Application.ProductName);
       } else
          v = Class1;
       //UPGRADE_WARNING: (1068) v of type Form1 is being forced to string.
       MessageBox.Show((string) v, Application.ProductName);

    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration