hi ,
I have written a follwing script :

Dim i,j,ub
ub = ubound(evnt.replacementParameters)

For i=0 to ub

j = evnt.replacementParameters(i)
.............
.............
Next

Where evnt.replacementParameters is an array of strings.
When debugging I can see upper bound as 3 and lower bound as 0.
But I am getting error at statement,
j = evnt.replacementParameters(i)

which says "Wrong Number of properties or invalid property assignment " with
err.number = 450.

I am not able to find what's going wrong!!?
While debugging , Watch for evnt.replacementParameters shows me all the four
values in that array,
but watch for evnt.replacementParameters(0) and evnt.replacementParameters(1)
shows empty!!!

Any help would be appreciated.
Thanks in advance.

Re: Help ! Wrong Number of properties or invalid property assignment ! by Joe

Joe
Thu Apr 28 11:28:43 CDT 2005

Hi,

"SQLReporter" <SQLReporter@discussions.microsoft.com> wrote in message
news:EFECC98A-034B-4EAF-B799-E59808A687E9@microsoft.com...
> hi ,
> I have written a follwing script :
>
> Dim i,j,ub
> ub = ubound(evnt.replacementParameters)
>
> For i=0 to ub
>
> j = evnt.replacementParameters(i)
> .............
> .............
> Next
>
> Where evnt.replacementParameters is an array of strings.
> When debugging I can see upper bound as 3 and lower bound as 0.
> But I am getting error at statement,
> j = evnt.replacementParameters(i)
>
> which says "Wrong Number of properties or invalid property assignment "
> with
> err.number = 450.
>
> I am not able to find what's going wrong!!?
> While debugging , Watch for evnt.replacementParameters shows me all the
> four
> values in that array,
> but watch for evnt.replacementParameters(0) and
> evnt.replacementParameters(1)
> shows empty!!!
>
> Any help would be appreciated.
> Thanks in advance.
>
Try this --

Assuming evnt is an object and replacementParameters is a return array
property, assign the array to a script array before articulating the
elements. Array property returns cannot generally be handled in the same
manner as collection returns.

Dim a,i,j,ub
a= evnt.replacementParameters
ub = ubound(a)

For i=0 to ub
j = a(i)
.............
.............
Next

Joe Earnest



Re: Help ! Wrong Number of properties or invalid property assignme by SQLReporter

SQLReporter
Fri Apr 29 01:28:02 CDT 2005

Thanks for response.
When I tried that i got following error.
"Type Mismatch" on the same line..
I found similar question at http://forums.devshed.com/t54920/s.html
but can't find answer :(
Any thoughts?

"Joe Earnest" wrote:

> Hi,
>
> "SQLReporter" <SQLReporter@discussions.microsoft.com> wrote in message
> news:EFECC98A-034B-4EAF-B799-E59808A687E9@microsoft.com...
> > hi ,
> > I have written a follwing script :
> >
> > Dim i,j,ub
> > ub = ubound(evnt.replacementParameters)
> >
> > For i=0 to ub
> >
> > j = evnt.replacementParameters(i)
> > .............
> > .............
> > Next
> >
> > Where evnt.replacementParameters is an array of strings.
> > When debugging I can see upper bound as 3 and lower bound as 0.
> > But I am getting error at statement,
> > j = evnt.replacementParameters(i)
> >
> > which says "Wrong Number of properties or invalid property assignment "
> > with
> > err.number = 450.
> >
> > I am not able to find what's going wrong!!?
> > While debugging , Watch for evnt.replacementParameters shows me all the
> > four
> > values in that array,
> > but watch for evnt.replacementParameters(0) and
> > evnt.replacementParameters(1)
> > shows empty!!!
> >
> > Any help would be appreciated.
> > Thanks in advance.
> >
> Try this --
>
> Assuming evnt is an object and replacementParameters is a return array
> property, assign the array to a script array before articulating the
> elements. Array property returns cannot generally be handled in the same
> manner as collection returns.
>
> Dim a,i,j,ub
> a= evnt.replacementParameters
> ub = ubound(a)
>
> For i=0 to ub
> j = a(i)
> .............
> .............
> Next
>
> Joe Earnest
>
>
>

Re: Help ! Wrong Number of properties or invalid property assignme by Joe

Joe
Fri Apr 29 05:34:21 CDT 2005

Hi,

"SQLReporter" <SQLReporter@discussions.microsoft.com> wrote in message
news:324AA5E4-C07B-41FA-9A7D-528376F1AD55@microsoft.com...
> Thanks for response.
> When I tried that i got following error.
> "Type Mismatch" on the same line..
> I found similar question at http://forums.devshed.com/t54920/s.html
> but can't find answer :(
> Any thoughts?
>
> "Joe Earnest" wrote:
>
>> Hi,
>>
>> "SQLReporter" <SQLReporter@discussions.microsoft.com> wrote in message
>> news:EFECC98A-034B-4EAF-B799-E59808A687E9@microsoft.com...
>> > hi ,
>> > I have written a follwing script :
>> >
>> > Dim i,j,ub
>> > ub = ubound(evnt.replacementParameters)
>> >
>> > For i=0 to ub
>> >
>> > j = evnt.replacementParameters(i)
>> > .............
>> > .............
>> > Next
>> >
>> > Where evnt.replacementParameters is an array of strings.
>> > When debugging I can see upper bound as 3 and lower bound as 0.
>> > But I am getting error at statement,
>> > j = evnt.replacementParameters(i)
>> >
>> > which says "Wrong Number of properties or invalid property assignment "
>> > with
>> > err.number = 450.
>> >
>> > I am not able to find what's going wrong!!?
>> > While debugging , Watch for evnt.replacementParameters shows me all the
>> > four
>> > values in that array,
>> > but watch for evnt.replacementParameters(0) and
>> > evnt.replacementParameters(1)
>> > shows empty!!!
>> >
>> > Any help would be appreciated.
>> > Thanks in advance.
>> >
>> Try this --
>>
>> Assuming evnt is an object and replacementParameters is a return array
>> property, assign the array to a script array before articulating the
>> elements. Array property returns cannot generally be handled in the same
>> manner as collection returns.
>>
>> Dim a,i,j,ub
>> a= evnt.replacementParameters
>> ub = ubound(a)
>>
>> For i=0 to ub
>> j = a(i)
>> .............
>> .............
>> Next
>>
>> Joe Earnest
>>


I believe that you've taken care of your first problem and moved on to a new
and different one.

I am at a disadvantage, without knowing what the object does or returns.
The error is occurring on the "j=a(i)" line, right? Do you know if you're
getting the error on your first iteration through the loop (element 0) or a
later one? Once a is assigned, have you tested it for array status with a
"0" lbound?

Whenever you're confused by a type mismatch error, put in a test line to see
what you've got. The problem could be on the left or right side. If you
formally dim or redim j as an array somewhere in your code, you may get this
error when you try to reset it to a scalar value. Another issue could be
that you're treating a as an array when it's not. If a(i) is an object, it
may require "set j= a(i)". Otherwise, VBS variables are all variant
subtypes and should reassign without problem. But more likely you're
getting the value issue from your object.

Try ...

...
msgbox typename(a)
msgbox isarray(a) & vbCr & lbound(a) & vnCr & ubound(a)
For i=0 to ub
msgbox typename(a(i)) & vbCr & isobject(a(i))
j = a(i)
...

Joe Earnest



Re: Help ! Wrong Number of properties or invalid property assignme by Joe

Joe
Fri Apr 29 06:59:54 CDT 2005

Oops ...

Typo: the "vnCr" in the next line should be "vbCr"

msgbox isarray(a) & vbCr & lbound(a) & vnCr & ubound(a)

Joe Earnest



Re: Help ! Wrong Number of properties or invalid property assignme by SQLReporter

SQLReporter
Fri Apr 29 09:56:07 CDT 2005

When I tried that i found ,

isarray(a) = true
typename(a) = "String()"
lbound(a) = 0
ubound(a) = 3
isobject(a) = false

typename(a(i)) = Empty
typename(a(0)) = Empty
typename(a(1)) = Empty
isobject(a(i)) = Empty

And when I dubug I can see -
(Consider following as a watch window)

NAME VALUE
TYPE

--- a {...}
Array of String
|-- (0) "4"
String
|-- (1) "Developement"
String
|-- (2) "Connection Successful"
String
|-- (3) "CLIENT"
String

From this it clarifies that all four array elements are strings.
But

a(i) Empty
User-defined Type
a(0) Empty
User-defined Type
a(1) Empty
User-defined Type

Above values take them as "User-defined Type".
How to find culprit?

for j - when I initialize it to "test" or "",
typename(j) "String"
String
So definitely j is string.

any thoughts ?

"Joe Earnest" wrote:

> Oops ...
>
> Typo: the "vnCr" in the next line should be "vbCr"
>
> msgbox isarray(a) & vbCr & lbound(a) & vnCr & ubound(a)
>
> Joe Earnest
>
>
>

Re: Help ! Wrong Number of properties or invalid property assignme by Joe

Joe
Fri Apr 29 18:40:43 CDT 2005

Hi,

"SQLReporter" <SQLReporter@discussions.microsoft.com> wrote in message
news:2FFCE0A6-5BAE-42B3-B613-72ABBD3D9509@microsoft.com...
> When I tried that i found ,
>
> isarray(a) = true
> typename(a) = "String()"
> lbound(a) = 0
> ubound(a) = 3
> isobject(a) = false
>
> typename(a(i)) = Empty
> typename(a(0)) = Empty
> typename(a(1)) = Empty
> isobject(a(i)) = Empty
>
> And when I dubug I can see -
> (Consider following as a watch window)
>
> NAME VALUE
> TYPE
>
> --- a {...}
> Array of String
> |-- (0) "4"
> String
> |-- (1) "Developement"
> String
> |-- (2) "Connection Successful"
> String
> |-- (3) "CLIENT"
> String
>
> From this it clarifies that all four array elements are strings.
> But
>
> a(i) Empty
> User-defined Type
> a(0) Empty
> User-defined Type
> a(1) Empty
> User-defined Type
>
> Above values take them as "User-defined Type".
> How to find culprit?
>
> for j - when I initialize it to "test" or "",
> typename(j) "String"
> String
> So definitely j is string.
>
> any thoughts ?
>

You're getting beyond my personal experience. As best I understand it, WSH
scripts seem to have a couple of well-known problems when it comes to
object-passed values. Your object appears to be hard-typing the return as a
string array.

While VBS can easily convert hard-typed scalar values to its variants, it
does not (by design) convert hard-typed ByRef variables -- either scalar or
array. Do you know if the object is passing the array value ByRef or ByVal?

I've also seen posts concerning the difficulty of converting hard-typed
arrays to variant arrays. Apparently the error occurs, as in your case, not
when the array is obtained, but when the elements are articulated.

On the off-chance that this easier than it seems, try the following, to see
if it cures the problem:

j= cstr(a(i))

If still stumped, you may need to re-post a new thread with the current
problem, to get the attention of someone at the NG, like one of the MVPs,
who writes objects.

In the meantime, gere are some 5-to-7-year-old threads that you might find
interesting:

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/e1f4c1c832db6897/25bb2c71dbd65e87?q=hard+typed+array+group:microsoft.public.scripting.*&rnum=1&hl=en#25bb2c71dbd65e87

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/6bc9f60808b40150/d64dcb44856ab814?q=hard+typed+array+group:microsoft.public.scripting.*&rnum=2&hl=en#d64dcb44856ab814

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/a6a8e45195522b75/416f1224f61d47d9?q=hard+array+type+group:microsoft.public.scripting.*&rnum=3&hl=en#416f1224f61d47d9

Regards,
Joe Earnest



Re: Help ! Wrong Number of properties or invalid property assignme by Joe

Joe
Fri Apr 29 18:47:48 CDT 2005

Hi,

This may show up as a second copy of the same post. I had trouble sending
the original response, and it hasn't shown up on my OE.

"SQLReporter" <SQLReporter@discussions.microsoft.com> wrote in message
news:2FFCE0A6-5BAE-42B3-B613-72ABBD3D9509@microsoft.com...
> When I tried that i found ,
>
> isarray(a) = true
> typename(a) = "String()"
> lbound(a) = 0
> ubound(a) = 3
> isobject(a) = false
>
> typename(a(i)) = Empty
> typename(a(0)) = Empty
> typename(a(1)) = Empty
> isobject(a(i)) = Empty
>
> And when I dubug I can see -
> (Consider following as a watch window)
>
> NAME VALUE
> TYPE
>
> --- a {...}
> Array of String
> |-- (0) "4"
> String
> |-- (1) "Developement"
> String
> |-- (2) "Connection Successful"
> String
> |-- (3) "CLIENT"
> String
>
> From this it clarifies that all four array elements are strings.
> But
>
> a(i) Empty
> User-defined Type
> a(0) Empty
> User-defined Type
> a(1) Empty
> User-defined Type
>
> Above values take them as "User-defined Type".
> How to find culprit?
>
> for j - when I initialize it to "test" or "",
> typename(j) "String"
> String
> So definitely j is string.
>
> any thoughts ?
>
> "Joe Earnest" wrote:
>
>> Oops ...
>>
>> Typo: the "vnCr" in the next line should be "vbCr"
>>
>> msgbox isarray(a) & vbCr & lbound(a) & vnCr & ubound(a)
>>
>> Joe Earnest

You're getting beyond my personal experience. As best I understand it, WSH
scripts seem to have a couple of well-known problems when it comes to
object-passed values. Your object appears to be hard-typing the return as a
string array.

While VBS can easily convert hard-typed scalar values to its variants, it
does not (by design) convert hard-typed ByRef variables -- either scalar or
array. Do you know if the object is passing the array value ByRef or ByVal?

I've also seen posts concerning the difficulty of converting hard-typed
arrays to variant arrays. Apparently the error occurs, as in your case, not
when the array is obtained, but when the elements are articulated.

On the off-chance that this easier than it seems, try the following, to see
if it cures the problem:

j= cstr(a(i))

If still stumped, you may need to re-post a new thread with the current
problem, to get the attention of someone at the NG, like one of the MVPs,
who writes objects.

In the meantime, gere are some 5-to-7-year-old threads that you might find
interesting:

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/e1f4c1c832db6897/25bb2c71dbd65e87?q=hard+typed+array+group:microsoft.public.scripting.*&rnum=1&hl=en#25bb2c71dbd65e87

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/6bc9f60808b40150/d64dcb44856ab814?q=hard+typed+array+group:microsoft.public.scripting.*&rnum=2&hl=en#d64dcb44856ab814

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/a6a8e45195522b75/416f1224f61d47d9?q=hard+array+type+group:microsoft.public.scripting.*&rnum=3&hl=en#416f1224f61d47d9

Regards,
Joe Earnest



Re: Help ! Wrong Number of properties or invalid property assignme by Michael

Michael
Fri Apr 29 20:06:53 CDT 2005

> typename(a) = "String()"

This is the key clue...it indicates an array of strongly typed (aka, native)
strings. Script clients can only deal arrays of variants of supported
subtype (typename would return "Variant()").

Try explicitly casting each element in the array to a string...

For i=lbound(a) to ubond(a)
a(i) = CStr(a(i))
Next


--
Michael Harris
Microsoft MVP Scripting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Please ask follow-up questions via the original newsgroup thread.




Re: Help ! Wrong Number of properties or invalid property assignme by Michael

Michael
Fri Apr 29 22:13:02 CDT 2005

> Try explicitly casting each element in the array to a string...
>
> For i=lbound(a) to ubond(a)
> a(i) = CStr(a(i))
> Next

If that doesn;t work...

SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
http://support.microsoft.com/kb/q250344/

If you go that route, you might want to look at this thread as well...

http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_frm/thread/2a139bcf7dd71e95/c838a1c106ab4737?tvc=1&q=arrayconvert++group:*.scripting+author:%22Michael+Harris%22&hl=en#c838a1c106ab4737

The followiwing quote is mine <grin>!

"...ArrayConvert is a just sample VB COM server supplied by MS for free.
You didn't really expect it to work as is, did you? The problem is the VB
source code is incorrect for the CStrArray method <g>! ..."



--
Michael Harris
Microsoft MVP Scripting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Please ask follow-up questions via the original newsgroup thread.




Re: Help ! Wrong Number of properties or invalid property assignme by SQLReporter

SQLReporter
Wed May 04 08:38:08 CDT 2005

Thank you Michael and Joe.
You are really a great help!!!
It finally worked and I had to use "Arrayconert" project provided by
microsoft...

Thank you again...

"Michael Harris (MVP)" wrote:

> > Try explicitly casting each element in the array to a string...
> >
> > For i=lbound(a) to ubond(a)
> > a(i) = CStr(a(i))
> > Next
>
> If that doesn;t work...
>
> SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
> http://support.microsoft.com/kb/q250344/
>
> If you go that route, you might want to look at this thread as well...
>
> http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_frm/thread/2a139bcf7dd71e95/c838a1c106ab4737?tvc=1&q=arrayconvert++group:*.scripting+author:%22Michael+Harris%22&hl=en#c838a1c106ab4737
>
> The followiwing quote is mine <grin>!
>
> "...ArrayConvert is a just sample VB COM server supplied by MS for free.
> You didn't really expect it to work as is, did you? The problem is the VB
> source code is incorrect for the CStrArray method <g>! ..."
>
>
>
> --
> Michael Harris
> Microsoft MVP Scripting
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Please ask follow-up questions via the original newsgroup thread.
>
>
>
>