Solved

VBScript and Multidimensional arrays

Posted on 1998-08-31
4
791 Views
Last Modified: 2012-06-27
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 ????
0
Comment
Question by:joeslow
  • 2
4 Comments
 
LVL 1

Expert Comment

by:CarlosJac
ID: 1432098
Is LBound(ValArray, 2) = 0 ?
0
 

Author Comment

by:joeslow
ID: 1432099
Yes it is
0
 
LVL 4

Accepted Solution

by:
mcix earned 100 total points
ID: 1432100
In the scGetValueArray method of the  MMLCmdObj object, make sure you define the ValArray parameter ByVal As Variant.

Like this:

Public Sub scGetValueArray(ByVal ParamName as Variant, ByVal ValArray As Variant)

Usually, a Type-Mismatch will occur if it is not declared in this fashion...


0
 

Author Comment

by:joeslow
ID: 1432101
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

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question