PDA

View Full Version : Passing an Array to another Array


macleodjb
01-14-2011, 02:04 AM
Hi Guys,

I'm not sure my title is correct but what i am trying to do is put an array that i got from another function into the code that i am running currently.

Example.

Dim NewArray(0 to 7) as Integer

NewArray = GetOldArray() <--- This function returns an array

I keep getting an error here saying "Value of type cannot be converted to 1 dimensional array".

I tried it couple different ways but it never works. I'm sure this is a stupid answer so thank you in advance.

macleodjb
01-14-2011, 02:39 AM
Ok i fixed my problem, i redimed the array and it worked fine. However i ran into a different problem now.

It's very strange, when i had the msgbox uncommented the code works fine and gives me random numbers for each selection. When i comment the msgbox out of the script it returns 1 random number and repeats it until done.


Do Until WhiteCount = PickQty
WhiteNumber = GetRandom_ArrayElement(WhiteChoicesArr)
TicketString(ArrayCount) = CType(WhiteNumber, String)
'MsgBox(WhiteNumber, MsgBoxStyle.OkOnly)
WhiteCount += 1
ArrayCount += 1
Loop


Any Suggestions?

Old Pedant
01-14-2011, 05:31 AM
Since you don't show your code for GetRandomArrayElement() I don't see how we can guess.

By the way, you appear to be in the wrong forum.


Dim NewArray(0 to 7) as Integer

That looks to me like VB code, not VBScript. And ASP code can't use VB code.

So I assume you are using ASP.NET, and that's a different forum.

[And are you aware that the contruct (0 to 7) is obsolete? In VB.NET, the lower bound is *ALWAYS* zero, so the "0 to" part is pointless. You get the same effect using Dim x(7) as you do from Dim x(0 to 7) ]