Link to home
Start Free TrialLog in
Avatar of joeslow
joeslow

asked on

VBScript and Multidimensional arrays

I get the following error when I run the VBscript below …

Error in the script at Line 5 and column 0
Type mismatch
Microsoft VBScript runtime error

The call below to the function scGetValueArray( ), of the MMLCmdObj object, retrieves the second argument as an array of values(strings). However, If I call the function IsArray() over ValArray, it returns TRUE meaning that it does recognize it as an array. Also, if I comment out the functions to retrieve the values of the array elements, the call to Ubound works fine too.


Sub SetInfo
Dim ParamName, ValArray, Upper, Counter, SQL
ParamName = "DIR"
call MMLCmdObj.scGetValueArray(ParamName, ValArray)
MsgBox ValArray(0,0) ''''''''''''''''''''''''''I get the error here
Upper = UBound(ValArray, 2)
For Counter = 0 To Upper
    SQL = "INSERT INTO extension (Type, startDir, endDir) " & vbNewLine
    SQL = SQL & " VALUES('ANA', " & CStr(ValArray(Counter,0)) &", "& CStr(ValArray(Counter,1)) &")"  '''''''''''''''''''''''''''''I get the error here too
    if Not MMLCmdObj.scInsertValues(SQL)Then
      Exit For
    End If
Next
End Sub

Any ideas ????
Avatar of CarlosJac
CarlosJac

Is LBound(ValArray, 2) = 0 ?
Avatar of joeslow

ASKER

Yes it is
ASKER CERTIFIED SOLUTION
Avatar of mcix
mcix

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joeslow

ASKER

Your reply lead me to find the correct answer to my problem which was actually in my C++ code.
I had the ValArray.vt defined as VT_ARRAY instead of VT_ARRAY | VT_VARIANT

Thank you