0

I am trying to create one more array from an existing array.

For that, I tried to set size of the new array from the size of existing array, but getting error.

---------------------------
Windows Script Host
---------------------------
Script: C:\Users\UReddy\Desktop\B.VBS
Line:   7
Char:   8
Error:  Expected integer constant
Code:   800A0402
Source:     Microsoft VBScript compilation error

---------------------------
OK   
---------------------------

My VBScript code:

Public Sub DisplayArray(aArray)
  MsgBox(Join(aArray, vbNewLine))
End Sub

Public Function getMSPVersions(aArray)
 maxSize = UBound(aArray)+1
 Dim a(maxSize)
 Dim sCount = -1
 For Each sValue in mspfilelist
  sCount = sCount + 1
  a[sCount] = ExtractVersionFromMSP(sValue)
 Next
 getMSPVersions=a
End Function

Public Function ExtractVersionFromMSP(txt)
txt1 = Replace(txt,"SizingSuite_","")
txt1 = Replace(txt1,"_Update","")
txt1 = Replace(txt1,".msp","")
ExtractVersionFromMSP=txt1
End Function

MsgBox(getMSPVersions(Array("SizingSuite_2.0.2.2_Update","SizingSuite_2.0.3.3_Update","SizingSuite_2.0.4.1_Update")))

Please suggest how to fix this.

uday kiran
  • 27
  • 6
  • 1
    Yes working with this, thank you. redim Preserve a(maxSize) – uday kiran Dec 20 '21 at 09:45
  • @LesFerch at least reference the [correct documentation](https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/c850dt17(v=vs.84)) for the language. – user692942 Dec 20 '21 at 11:16
  • @user692942 Oops. I was on mobile and didn't notice I was on a vb.net page instead of a VBScript page. Thanks for posting the correct link. – LesFerch Dec 20 '21 at 13:53

0 Answers0