Page 1 of 2 12 LastLast
Results 1 to 40 of 72

Thread: Windows August 2019 Update break VB arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Angry Windows August 2019 Update break VB arrays

    Hi,

    We've just today had a number of VB6 apps die with various 'Error 5' messages.

    One was an app we have the source for, and it appears that the August 2019 cumulative update has broken variant arrays ( also in VBA I see mention of on Twitter ). Uninstalling the update fixes everything.

    Is anyone else seeing the issue? if so, is it confined to variant arrays, or is the breakage wider?

    Thanks

  2. #2
    New Member
    Join Date
    May 2019
    Posts
    1

    Re: Windows August 2019 Update break VB arrays

    We work with a ERP and this morning some of ours clients had Error 5 messages. The ERP vendor issue a patch that fixed the issue, but for now they didn't share much information about it

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Windows August 2019 Update break VB arrays

    Do you have a test case exhibiting failures?

    So far the only glitch I found was:

    Code:
    Private Data() As Variant
    .
    .
    .
    Private Sub Something()
        Data = Array() 'Error 5 here!
    End Sub
    I was able to fix that by using:

    Code:
    Private Declare Function VariantArray Lib "oleaut32" Alias "SafeArrayCreateVector" ( _
        Optional ByVal VT As VbVarType = vbVariant, _
        Optional ByVal LB As Long = 0, _
        Optional ByVal cElements As Long = 0) As Variant()
    
    Private Data() As Variant
    .
    .
    .
    Private Sub Something()
        Data = VariantArray()
    End Sub
    Last edited by dilettante; Aug 14th, 2019 at 02:36 PM.

  4. #4
    New Member
    Join Date
    Mar 2018
    Posts
    5

    Re: Windows August 2019 Update break VB arrays

    We're also encountering issues concerning ParamArrays as is described in this topic: https://answers.microsoft.com/en-us/...0-0a220f1656e9
    Microsoft stating that a security fix caused the issue and they're working on a solution for this particular issue.

    @dilettante I'd suggest you add that specific error to the topic.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by dilettante View Post
    Do you have a test case exhibiting failures?
    Thanks for replying - the office is closed now, so I'll need to check with a colleague to exactly what test cases they'd narrowed down.

    Useful info on the fix - I'll bring that up tomorrow

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Windows August 2019 Update break VB arrays

    Looks like there is more:

    Microsoft Pushing VBScript A Little Closer To the Edge

    "The change to disable VBScript will take effect in the upcoming cumulative updates for Windows 7, 8, and 8.1 on August 13th, 2019. VBScript will be disabled by default for Internet Explorer 11 and WebOCs for Internet and Untrusted zones on all platforms running Internet Explorer 11. This change is effective for Internet Explorer 11 on Windows 10 as of the July 9th, 2019 cumulative updates."
    Not as big a deal for most people, but it will probably burn a few.


    So why has Microsoft a down on all things Basic?

    I don't think this is quite the story. I don't think Microsoft cares much about anything other than Azure and a future place in the cloud. In this nebulous environment languages are irrelevant - apart from JavaScript and perhaps Python. This is the reason Microsoft is no longer an innovator and leader in the dev world. Instead what we have is the dragging of old carcasses around, the occasional spark when someone notices a way to revitalize an old technology, yes Blazor I'm looking at you, and then a confusing mess of open sourcing and deprecations.
    I think this pretty much sums up the advancing senility of a once-great company.

  7. #7
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: Windows August 2019 Update break VB arrays

    So is it just the Array keyword or are other means of declaring/populating a Variant array with array members effected?

  8. #8
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: Windows August 2019 Update break VB arrays

    In the long run, using Microsoft's platforms and tools is a huge disaster. Those who use non-Microsoft environments from the start are lucky. This is why I don't want to use ASP and VBS that Olaf often recommends.

    Microsoft is the only big company that doesn't care about users and consumers at all, but lives well.

    Very curious, what is the next company to replace Microsoft, although Microsoft is still very strong.
    Last edited by dreammanor; Aug 14th, 2019 at 09:21 PM.

  9. #9
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    I found the problem trying to create a "ragged" 2-dimensional Variant array with the following line of code:

    vntArray = Array(Array( ), Array( ), Array( ), Array( ))

    This will not work either:

    vntA = Array( )
    vntB = Array( )
    vntC = Array(vntA, vntB) 'Fails here trying to add empty arrays into array

    However, this is fine...

    Redim vntA(0)
    Redim vntB(0)
    vntC = Array(vntA, vntB) 'OK, because the arrays A and B are NOT empty; They each contain 1 (empty) element at index 0.

  10. #10
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    I found the problem trying to create a "ragged" 2-dimensional Variant array with the following line of code:

    vntArray = Array(Array( ), Array( ), Array( ), Array( ))

    This will not work either:

    vntA = Array( )
    vntB = Array( )
    vntC = Array(vntA, vntB) 'Fails here trying to add empty arrays into array


    However, this is fine...

    Redim vntA(0)
    Redim vntB(0)
    vntC = Array(vntA, vntB) 'OK, because the arrays A and B are NOT empty; They each contain 1 (empty) element at index 0.

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by fafalone View Post
    So is it just the Array keyword or are other means of declaring/populating a Variant array with array members effected?
    It sounds like calling a procedure with a ParamArray argument also fails when none are provided. See the link in post #4 above.

  12. #12
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: Windows August 2019 Update break VB arrays

    Yes, got my first customer with an error 5.
    In the IFileDialog class by LaVolpe, indeed on an empty ParamArray
    I added an additional parameter Empty when the function is originally called with only 2 parameters.
    And I added error handling, would an OERN catch this error 5?

    We don't have this security update yet on the office so I can't test a basic fix.

    Code:
    Private Function pvCallFunction_COM(ByVal InterfacePointer As Long, ByVal VTableOffset As InterfaceMethodOffsets, _
                                ParamArray FunctionParameters() As Variant) As Variant
    
    ' Used to call active-x or COM objects, not standard dlls
    ' Return value. Will be a variant containing a value of FunctionReturnType
    '   If this method fails, the return value will always be Empty. This can be verified by checking
    '       the Err.LastDLLError value. It will be non-zero if the function failed else zero.
    '   If the method succeeds, there is no guarantee that the Interface function you called succeeded. The
    '       success/failure of that function would be indicated by this method's return value.
    '       Typically, success is returned as S_OK (zero) and any other value is an error code.
    '   If calling a sub vs function & this method succeeds, the return value will be zero.
    '   Summarizing: if method fails to execute, Err.LastDLLError value will be non-zero
    '       If method executes ok, if the return value is zero, method succeeded else return is error code
    
    ' Parameters:
    '   InterfacePointer. A pointer to an object/class, i.e., ObjPtr(IPicture)
    '       Passing invalid pointers likely to result in crashes
    '   VTableOffset. The offset from the passed InterfacePointer where the virtual function exists.
    '       The value is in bytes. These offsets are generally in multiples of 4. Value cannot be negative.
    '       Example: to call IUnknown:Release, CallFunction_COM InterfacePointer, 8&, CR_LONG, CC_STDCALL
    
        '// minimal sanity check for these 3 parameters:
        If VTableOffset < 0& Then Exit Function
    
        Dim pIndex As Long, pCount As Long, bRelease As Boolean
        Dim vParamPtr() As Long, vParamType() As Integer
        Dim vRtn As Variant, vParams() As Variant
        Const CallConvention As Long = 4&                   ' STDCALL
    
        vParams() = FunctionParameters()                    ' copy passed parameters, if any
        On Error Resume Next
        If IsEmpty(vParams(0)) Then
          pCount = 0
        Else
          pCount = Abs(UBound(vParams) - LBound(vParams) + 1&)
        End If
        On Error GoTo 0
        
        If pCount = 0& Then                                 ' no return value (sub vs function)
            ReDim vParamPtr(0 To 0)
            ReDim vParamType(0 To 0)
        Else
            ReDim vParamPtr(0 To pCount - 1&)               ' need matching array of parameter types
            ReDim vParamType(0 To pCount - 1&)              ' and pointers to the parameters
            For pIndex = 0& To pCount - 1&
                vParamPtr(pIndex) = VarPtr(vParams(pIndex))
                vParamType(pIndex) = VarType(vParams(pIndex))
            Next
        End If
                                                            ' call the function now
        pIndex = DispCallFunc(InterfacePointer, VTableOffset, CallConvention, vbLong, _
                              pCount, vParamType(0), vParamPtr(0), vRtn)
        If pIndex = 0& Then                                 ' 0 = S_OK
            pvCallFunction_COM = vRtn                       ' return result
        Else
            SetLastError pIndex                             ' set error & return Empty
        End If
    
    End Function
    **UPDATE: the customer has tested this version on his updated W10 machine and reported that the application works again.
    Last edited by Arnoutdv; Aug 15th, 2019 at 07:16 AM.

  13. #13
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: Windows August 2019 Update break VB arrays

    Quoted below was code that doesn't work:

    Code:
    Private Data() As Variant
    
    Private Sub Something()
        Data = Array() 'Error 5 here!
    End Sub
    This will work if you start
    Code:
    Private Data as Variant
    However the following will not:
    Code:
    Private Data As Variant
    Private Data2 as Variant
    
    Private Sub Something()
        Data = Array() 
        Data2 = Data 'Error 5 here
    End Sub
    Any attempt to assign an empty array to a new variant fails. It can be passed by reference to a new procedure as a parameter, but not by value. It doesn't matter how the empty array is produced - e.g. a ParamArray with no parameters can be assigned to a variant but this cannot then be passed to another variant.

  14. #14
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    I just run into this problem (today, 15th of Aug): assigning implicit empty arrays to variant variables does not work any longer:
    Dim Arr as variant
    and then
    Arr = Array()
    causes “invalid procedure call error”
    I solved this by assigning empty arrays explictly:
    Arr = Array(Empty)

  15. #15
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    I just run into this problem (today, 15th of Aug): assigning implicit empty arrays to variant variables does not work any longer:
    Dim Arr as variant
    and then
    Arr = Array()
    causes “invalid procedure call error”
    I solved this by assigning empty arrays explictly:
    Arr = Array(Empty)

  16. #16
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: Windows August 2019 Update break VB arrays

    Array(Empty) is not an empty array. It is an array containing a single element which is Empty.

  17. #17
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    Solution:
    Code:
    Private Data As Variant
    Private Data2 As Variant
    
    Private Sub Something()
        Data = Split("", "|")
        Data2 = Data
    End Sub

  18. #18
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Windows August 2019 Update break VB arrays

    Solution:
    Code:
    Private Data As Variant
    Private Data2 As Variant
    
    Private Sub Something()
        Data = Split("", "|")
        Data2 = Data
    End Sub

  19. #19
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: Windows August 2019 Update break VB arrays

    And very interesting that it is possible to pass an empty string array to a second variant, but not an empty variant array.

  20. #20
    Hyperactive Member
    Join Date
    Jan 2018
    Posts
    264

    Re: Windows August 2019 Update break VB arrays

    I see that the KB lists Windows 7 SP1 as affected. Has anyone run into it there yet?

    Edit: OK, I see it listed specifically as part of the August update in KB4512506...
    Last edited by ahenry; Aug 15th, 2019 at 06:20 PM.

  21. #21
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Windows August 2019 Update break VB arrays

    The ParamArray case might be the one most often encountered in legacy code. But a fix for that (if we get one) should address calls to the Array() function as well as other intrinsic functions using variable length parameter lists. Most of those would be unlikely to ever have an empty parameter list though.

  22. #22
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Windows August 2019 Update break VB arrays

    Btw, what is the diffrence b/n SafeArrayCreateVector() and Array() constructed empty arrays? Flags like FADF_AUTO?

    cheers,
    </wqw>

  23. #23
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by wqweto View Post
    Btw, what is the diffrence b/n SafeArrayCreateVector() and Array() constructed empty arrays? Flags like FADF_AUTO?
    There's nothing wrong with the Right-Hand-Side (the Emtpy-Array-Construction in both cases).
    E.g. this code works without problems (printing -1):
    Code:
    Private Sub Form_Load()
      Debug.Print UBound(Array())
    End Sub
    So, (empty) ParamArrays as well as empty-arrays returning functions are "safe to use directly" (e.g. as a passed argument).

    The error only comes into play in assignments, when two conditions are met.
    1) the Right-Hand-Side has to be an empty Variant-Array (if the array contains at least one Member, everything's fine)
    2) the Left-Hand-Side has to be of Type Variant-Array (normal Variants will work as the LHS-target)

    SafeArrayCreateVector works (despite of the above met conditions), because the assignment-code the compiler generates, is different (due to API-calling) from the assigment-code the compiler generates in case of a simple:
    Dim Arr(): Arr = Array()

    Olaf
    Last edited by Schmidt; Aug 16th, 2019 at 06:41 AM.

  24. #24
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by Schmidt View Post
    SafeArrayCreateVector works (despite of the above met conditions), because the assignment-code the compiler generates, is different (due to API-calling) from the assigment-code the compiler generates
    I did some tests yesterday

    thinBasic Code:
    1. Option Explicit
    2.  
    3. Private Declare Function VariantArray Lib "oleaut32" Alias "SafeArrayCreateVector" ( _
    4.     Optional ByVal VT As VbVarType = vbVariant, _
    5.     Optional ByVal LB As Long = 0, _
    6.     Optional ByVal cElements As Long = 0) As Variant()
    7.    
    8. Private Sub Form_Load()
    9.     Debug.Print UBound(Test)
    10.     Debug.Print UBound(Test2)
    11. End Sub
    12.  
    13. Private Function Test() As Variant
    14.     Dim vRet As Variant
    15.     vRet = Array()
    16.     Test = vRet '  Err.Number=5, Err.Description=Invalid procedure call or argument
    17. End Function
    18.  
    19.  
    20. Private Function Test2() As Variant
    21.     Dim vRet As Variant
    22.     vRet = VariantArray()
    23.     Test2 = vRet '  Works
    24. End Function

    Didn't peek at the disassembly but the line the error is generated looks the same in Test vs Test2 -- it has to be flags in vRet IMO

    cheers,
    </wqw>

  25. #25
    New Member
    Join Date
    Aug 2019
    Posts
    4

    Re: Windows August 2019 Update break VB arrays

    The error also occurs when
    1) the right hand side is a variant to which an empty Variant array (e.g. Array()) has already been assigned.
    2) the left hand side is a normal Variant (not an array).

    The construct Array() with no parameters is incredibly useful. When a varaible is going to be processed as an array, but there are no values, assigning Array() to it means that the loop which processes the array needs no extra code for no value, by looping from the lbound to the ubound the loop exits immediately. ParamArray with no parameters is also a common and useful construct.

  26. #26
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by wqweto View Post
    Code:
    Private Function Test2() As Variant
           Dim vRet As Variant
               vRet = VariantArray()
               Test2 = vRet '  Works
    End Function
    Didn't peek at the disassembly but the line the error is generated looks the same in Test vs Test2 -- it has to be flags in vRet IMO
    Interesting code-snippet (the test2 above) - it supports your flags-theory strongly.

    FWIW, here's an alternative for your Test1, which works with the Array() function:
    Code:
    Private Sub Form_Load()
      Debug.Print UBound(GetEmptyArray())
    End Sub
    
    Function GetEmptyArray() As Variant
      GetEmptyArray = Array()
    End Function
    I guess the above works, because the assignment in the last line of GetEmptyArray() does not really make a copy-attempt.

    Olaf

  27. #27
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Windows August 2019 Update break VB arrays

    Just took a look at the content of the different SafeArray-descriptors with the following code:
    Code:
    Option Explicit
    
    Private Declare Function GetMem4 Lib "msvbvm60" (Src As Any, Dst As Any) As Long
    Private Declare Function VariantArray Lib "oleaut32" Alias "SafeArrayCreateVector" ( _
        Optional ByVal VT& = vbVariant, Optional ByVal LB&, Optional ByVal cElements&) As Variant()
    
    Private Sub Form_Load()
      Test1 Array()
      Test2 VariantArray()
    End Sub
     
    Private Sub Test1(Arr)
      Dim pSA As Long, DimsAndFlags As Long, pData As Long
          GetMem4 ByVal VarPtr(Arr) + 8, pSA
          GetMem4 ByVal pSA, DimsAndFlags
          GetMem4 ByVal pSA + 12, pData
      Debug.Print "Dims:"; DimsAndFlags And &HFFFF&, "Flags: "; Hex(DimsAndFlags \ 65536), "pData:"; pData
    End Sub
     
    Private Sub Test2(Arr)
      Dim pSA As Long, DimsAndFlags As Long, pData As Long
          GetMem4 ByVal VarPtr(Arr) + 8, pSA
          GetMem4 ByVal pSA, DimsAndFlags
          GetMem4 ByVal pSA + 12, pData
      Debug.Print "Dims:"; DimsAndFlags And &HFFFF&, "Flags: "; Hex(DimsAndFlags \ 65536), "pData:"; pData
    End Sub
    And the result for the VB6-Array() function was:
    Dims: 1 ... Flags: 880 ... pData: 0

    Whereas for the API-generated empty-array the result was:
    Dims: 1 ... Flags: 2880 ... pData: 7266680

    So, the Array()-function does have the set Flags-Combination of:
    FADF_VARIANT OR FADF_HAVEVARTYPE

    Whereas the API-returned SafeArray had an additional Flag set:
    FADF_VARIANT OR FADF_HAVEVARTYPE OR FADF_CREATEVECTOR
    ... as well as apparently an allocation in the pData-Member

    Which one of the two things (the additional FADF_CREATEVECTOR = &H2000 or a valid allocation in pData) makes the difference in assignments, we'll still have to figure out.
    (my money is on the "valid allocation in pData").

    HTH

    Olaf
    Last edited by Schmidt; Aug 16th, 2019 at 08:06 AM.

  28. #28
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by Schmidt View Post
    (my money is on the "valid allocation in pData")
    I agree, but it is only a hunch. This might be a factor in the "security issue" Microsoft tried to patch as well.

  29. #29
    Hyperactive Member
    Join Date
    Jan 2018
    Posts
    264

    Re: Windows August 2019 Update break VB arrays

    I ran into this case when looking at the ParamArray problem. In the IDE, it raised Error 5 like the other examples. But when compiled, it just crashes:

    Code:
    Private Sub Command1_Click()
        Dim varReturn As Variant
        On Error GoTo Err_Trap
        
        varReturn = DoSomething(1)
        varReturn = DoSomething()
        
        Exit Sub
    Err_Trap:
        MsgBox Err.Number
    End Sub
    
    Private Function DoSomething(ParamArray Arguments()) As Variant
        DoSomething = DoSomething2(Arguments)
    End Function
    
    Private Function DoSomething2(ParamArray Arguments()) As Variant
        DoSomething2 = Arguments
    End Function
    It is trying to copy a one-entry Variant array containing the empty variant array, and causes an access violation if compiled with optimization.

    Edit: If I add a minimal error handler to DoSomething2, it prevents the application crash:

    Code:
    Private Function DoSomething2(ParamArray Arguments()) As Variant
        On Error GoTo Err_Trap
        
        DoSomething2 = Arguments
        
        Exit Function
    Err_Trap:
        Err.Raise Err.Number, Err.Source, Err.Description
    End Function
    Last edited by ahenry; Aug 16th, 2019 at 03:11 PM.

  30. #30
    Frenzied Member
    Join Date
    Jun 2012
    Location
    Australia
    Posts
    1,162

    Re: Windows August 2019 Update break VB arrays

    So far it seems that the problem is only with Variants or arrays (both?). Anything else?
    Thanks all !

  31. #31
    Hyperactive Member
    Join Date
    Jan 2018
    Posts
    264

    Re: Windows August 2019 Update break VB arrays

    So far we've seen the error raised by:
    Assigning (by value) an empty array (or an array containing an empty array) to a variant, where that empty array comes from:
    1) A ParamArray with no arguments, like Array(), but also in user code with ParamArrays

    Code:
    Dim varValue as Variant
    Dim varValue2 as Variant
    Dim varArray() as Variant
    
    varValue = Array() ' OK?
    varValue2 = varValue ' Nope
    varArray = Array() ' Nope
    2) An empty array of Object,Class, or public UDT(?) that is (presumably) converted to a variant array

    Code:
    Dim ObjectArray() As Object
    Dim ClassArray() As Class1
    varValue = ObjectArray ' Nope
    varValue = ClassArray ' Nope
    Empty arrays created via SafeArrayCreateVector and Dim varArray() as Variant seem to be OK.

    I tested this in VB6, VBA may have different rules.
    Last edited by ahenry; Aug 16th, 2019 at 05:10 PM.

  32. #32
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: Windows August 2019 Update break VB arrays

    Hi, it may not be related to this problem, but since the update on Friday, August 9, the listviews with more than one tab gives the error: 372 failed to load control 'ListView' from mscomctl.ocx.
    But instead if there is only one tab, the ListView control is displayed perfectly.
    I already uninstalled the updates from friday and re-registered mscomctl.ocx but without success.

  33. #33
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: Windows August 2019 Update break VB arrays

    Hi, it may not be related to this problem, but since the update on Friday, August 9, the listviews with more than one tab gives the error: 372 failed to load control 'ListView' from mscomctl.ocx.
    But instead if there is only one tab, the ListView control is displayed perfectly.
    I already uninstalled the updates from friday and re-registered mscomctl.ocx but without success.

  34. #34
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Windows August 2019 Update break VB arrays

    ListViews have "tabs?" I'm not sure what you meant by that.

  35. #35
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,373

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by MBOS View Post
    We're also encountering issues concerning ParamArrays as is described in this topic: https://answers.microsoft.com/en-us/...0-0a220f1656e9
    Microsoft stating that a security fix caused the issue and they're working on a solution for this particular issue.
    When reading the latest posts in the linked discussion MS has now put an hotfix for this.
    It should be available in the coming days via Microsoft Update Catalog or Windows Server Update Services.

  36. #36
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by ahenry View Post
    So far we've seen the error raised by:
    Assigning (by value) an empty array (or an array containing an empty array) to a variant, where that empty array comes from:
    1) A ParamArray with no arguments, like Array(), but also in user code with ParamArrays

    Code:
    Dim varValue as Variant
    Dim varValue2 as Variant
    Dim varArray() as Variant
    
    varValue = Array() ' OK?
    varValue2 = varValue ' Nope
    varArray = Array() ' Nope
    2) An empty array of Object,Class, or public UDT(?) that is (presumably) converted to a variant array

    Code:
    Dim ObjectArray() As Object
    Dim ClassArray() As Class1
    varValue = ObjectArray ' Nope
    varValue = ClassArray ' Nope
    Empty arrays created via SafeArrayCreateVector and Dim varArray() as Variant seem to be OK.

    I tested this in VB6, VBA may have different rules.

    I tested these in Office 2019 pro plus/VBA on a new hp device with Windows 10 pro (1903).
    The only difference is "varValue2 = varValue".

    Code:
    Private Data() As Variant
    
    Dim varValue As Variant
    Dim varValue2 As Variant
    Dim varArray() As Variant
    
    Dim ObjectArray() As Object
    Dim ClassArray() As Class1
    
    Private Sub UserForm_Click()
       Something
    End Sub
    
    Private Sub Something()
    'Data = Array()'Error 5 here!
        
    'varValue = Array() ' OK
    'varValue2 = varValue ' OK
    'varArray = Array() ' 'Error 5 here!
    
    'varValue = ObjectArray ' 'Error 5 here!
    'varValue = ClassArray ' 'Error 5 here!
    End Sub
    Same thing happens with VB6.5 (VBA 2007).

  37. #37
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: Windows August 2019 Update break VB arrays

    Ssorry. I was expressed wrong. I am creating new listviews at runtime that remain as tabs but in reality it is an array of listview objects. When I add the second Listview object, the mentioned error appears. Sorry for my poor English.

  38. #38
    Hyperactive Member
    Join Date
    Jan 2018
    Posts
    264

    Re: Windows August 2019 Update break VB arrays

    Quote Originally Posted by TTn View Post
    I tested these in Office 2019 pro plus/VBA on a new hp device with Windows 10 pro (1903).
    The only difference is "varValue2 = varValue".
    Yeah, that surprised me in VB6 too. I bet that there are more variations of assigning / reassigning that I missed.

  39. #39
    Member
    Join Date
    Oct 2018
    Posts
    59

    Re: Windows August 2019 Update break VB arrays

    This appears to be a BUG, ​​but it should not be a deprecated feature. I use the latest version of Windows Insider and this problem does not happen.

  40. #40
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: Windows August 2019 Update break VB arrays

    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width