?
Solved

VBScript and Multidimensional arrays

Posted on 1998-08-31
4
Medium Priority
?
796 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 200 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, left to enroll

800 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