Solved

VBScript and Multidimensional arrays

Posted on 1998-08-31
4
795 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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