Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to assign an array return value
#1
Not Solved Sad 
Hi!

First, I have to admit, I actually am a Java guy and regularly lose my temper with VBScript's inconsistancy. So I might have already created a blind spot. But I still dont get this:

I have a function that returns an array (pasted later), and for some reason when I call it and want to assign it to a variable it tells me "Object required". AND NOTHING else (what an excellently accurate error message).

the line that produces the error:

set indices=stringTokenize("1;3;4;6;7;10", ";")

(I tried a dim indices() and dim indices(6) and much more before calling this function).

The function itself works, when I debug it to the end the return value is the correct array, but as soon as it jumps out of the function and should assign the return value to "indices" it comes up with this superweird error message.

Maybe its necessary to see the method in order to help me, so here it is, but I think its pretty irrelevant.

Function stringTokenize(wholeString, delimiter)
dim pos, i, found, lastPos
redim allTokens(0)

pos=1
i=0
found=0
While pos>0
ReDim preserve allTokens(i)
lastPos=pos
pos=instr(lastPos, wholeString, delimiter)
if(pos>0) then
allTokens(i)=mid(wholeString, lastPos, pos-lastPos)
pos=pos+1
else
allTokens(i)=mid(wholeString, lastPos)
end if
found=found+1
i=i+1

Wend
stringTokenize=allTokens
End Function
----------------------------------------

So why do I get this "Object required" error? Which object is required? The Strings surely not...


THANK YOU VERY MUCH!!!
CC
Reply


Messages In This Thread
How to assign an array return value - by ConstantChange - 01-15-2008, 10:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Childobject return wrong checkbox count.. VpnQTP 1 3,230 04-09-2015, 09:07 PM
Last Post: babu123
  SQL on oracle database doesn't return a value Bluefields 2 3,729 07-09-2012, 01:23 PM
Last Post: Bluefields
  Return reusable object HelenN 0 4,687 04-20-2011, 08:31 PM
Last Post: HelenN
  VBScript - How to get the Function return value iamsekhar 2 23,499 09-13-2010, 04:16 PM
Last Post: lotos
  How to use Array of Array in QTP dineshb 1 16,996 12-12-2009, 02:00 AM
Last Post: rdemers25

Forum Jump:


Users browsing this thread: 1 Guest(s)