Re: Type Mismatch Problem in VB
From: Kollin Patten (kollin_at_powerworld.com)
Date: 08/27/04
- Next message: Tom Lavedas: "RE: Calling functions in another .VBS"
- Previous message: Steven: "Create Function in Excel for connecting to Win Cluster"
- In reply to: Tim Newman: "Re: Type Mismatch Problem in VB"
- Messages sorted by: [ date ] [ thread ]
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.
>
>
- Next message: Tom Lavedas: "RE: Calling functions in another .VBS"
- Previous message: Steven: "Create Function in Excel for connecting to Win Cluster"
- In reply to: Tim Newman: "Re: Type Mismatch Problem in VB"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|