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(S QL)Then
Exit For
End If
Next
End Sub
Any ideas ????
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(
MsgBox ValArray(0,0) ''''''''''''''''''''''''''
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)) &")" ''''''''''''''''''''''''''
if Not MMLCmdObj.scInsertValues(S
Exit For
End If
Next
End Sub
Any ideas ????
Is LBound(ValArray, 2) = 0 ?
ASKER
Yes it is
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
I had the ValArray.vt defined as VT_ARRAY instead of VT_ARRAY | VT_VARIANT
Thank you