Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array used as function arguments

Status
Not open for further replies.

fluxdemon

MIS
Nov 5, 2002
89
US
I get "Error Type: Microsoft VBScript compilation (0x800A03EE) Expected ')'" for

dim pArray()

call testing("1","2","")

public function testing(pArray(0),pArray(1),pArray(2))
for each item in pArray
if pArray(item)="" then pArray(item)="0"
response.write(pArray(item))
next item
end function

Is it possible to assign values to an array being used as sub/function arguments?
 
It would be simpler to pass an array to the function, making a static sized array every single time seems a bit less then useful. You could just as easily just:
Code:
Dim myArray(2)
myArray(0) = "1"
myArray(1) = "2"
myArray(2) = "0"

If you really wanted to make a function that returned an array for a fixed number of agruments you could do something like:
Code:
Function Testing(val1, val2, val3)
   Dim pArray, ctr
   pArray = Array(val1, val2, val3)
   For ctr = 0 to UBound(pArray)
      If pArray(ctr) = "" Then pArray(ctr) = "0"
   Next
   Testing = pArray
End Function

Dim MyArray
MyArray = Testing("1","2","")

I'm not sure I see where this could be applied, however.

-T


01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top