Re: Type Mismatch Problem in VB

From: Kollin Patten (kollin_at_powerworld.com)
Date: 08/27/04


Date: Fri, 27 Aug 2004 09:44:42 -0500

Thanks for the suggestion Tim, I am trying to explore all angles. I
thought I could do as you suggested at first, too, but strangely it does
not work. I still get a type mismatch error.

I may need to better explain where the value is coming from and where it
is getting assigned to, as it may be something in the data structure(s)
I am dealing with that is causing the problem.

First, let me define the data array I am extracting from. It is a
jagged array.

DataArray = ["string",[array of long]]

thus dimension 1 (index 0) is just a string, but dimension 2 (index 1)
is an array of long integers.

**********************************************************
Code snippet:

for i = LBound(DataArray(1)(0)) to UBound(DataArray(1)(0))
     Dim valueList()
     valueList(0) = DataArray(1)(0)(i)
     valueList(1) = 1
     valueList(2) = "YES"
     ...
     valueList(x) = # or string
     processValueList(valueList)
next
**********************************************************

So basically all I am trying to do is extract a value from the array of
long integers, which is passed to the script as the second "dimension"
of a jagged array, and assign it as the first entry in a new array. It
seems that VBScript does not let me assign a value from the dataArray to
a position in the valueList array unless it is already type Variant.
But since the array is returning long integers, it gives me a type
mismatch error. I don't understand why it would be the case, so I am
looking for an answer to what I am doing wrong, or how to get around the
problem.

Thanks,

Kollin P.

Tim Newman wrote:
> Force a type change during assignment or comparison....
>
> var = CStr(longarr(index)) converts array index value to a string.
> There are many other type conversion functions.
>
> If I'm way off here, just ignore me, I'm not a proper coder.
>
>
>>>>Kollin Patten<kollin@powerworld.com> 8/26/2004 4:27:32 PM >>>
>
>
> Hi,
>
> I am new to writing a VB script, and have encountered what I consider to
> be a strange issue.
>
> One of the inputs to the script from a COM connection is an array of
> type Long. If I try to march through the list of long integers and
> assign the value at each index position to a variable in the VB Script,
> I get a type mismatch error. From some extensive searching for VB
> Script documentation, it seems that the VB Script only recognizes
> variant types. So my question is, is there a way around this in VB
> Script so that it will accept the array of Long Ints? I have actually
> gone to the COM side and temporarily changed the array to store the Long
> Ints as Variants and return the array of Variants, and in this case the
> VB Script code works perfectly. However, I cannot make the change to
> the COM object to return Variants instead of integers a permanent one
> because of many reasons, so I am searching for a solution on the VB
> Script side instead.
>
> Any ideas?
>
> Thanks,
> Kollin P.
>
>



Relevant Pages

  • Re: Logon script - function array and select case not working
    ... this all works well, except, the function i am using for the rules in the control script causes alot of querrys to AD. as there are alot of groups. ... objTSout.writeline retrv ... So if you think that this will assign an array value to the variable, how do you think the case select statement is going go compare this array value with the literal string values such as "group name here"? ... However, by not assigning ANY value to checkgrp in the function, you are guaranteeing that, should the function ever exit, it will return no information. ...
    (microsoft.public.scripting.vbscript)
  • Re: string retrieval issue
    ... Chicago Bears|NFC North ... not writing the third element back to the array). ... You didn't include it in your script. ... Fear is the mind-killer. ...
    (comp.lang.perl.misc)
  • Re: Type Mismatch Problem in VB
    ... var = CStr) converts array index value to a string. ... I am new to writing a VB script, and have encountered what I consider to ... Ints as Variants and return the array of Variants, ...
    (microsoft.public.scripting.vbscript)
  • Re: even rows for checkbox forms with no splitting of boxes from values
    ... 'mod' on the array length with a denominator equal to the width of the row, ... State saving really depends on what the script is already doing. ... So I usually roll my own checkboxes. ... #this is to create an array with 25-50 strings 2-10 in length ...
    (comp.infosystems.www.authoring.cgi)
  • Re: settimeout needs alert() ???
    ... function slider { ... and use script to replace the src and title attributes. ... are downloaded completely. ... The usual strategy is to load all of the images in to an array of image ...
    (comp.lang.javascript)

Quantcast