By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,482 Members | 3,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,482 IT Pros & Developers. It's quick & easy.

VBScript function returning multiple values

P: n/a
Is there a way to return multiple values from a function without using an
array? Would a dictionary object work better?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #1
Share this Question
Share on Google+
17 Replies


P: n/a
"Roland Hall" <nobody@nowhere> wrote in message
news:uJ*************@TK2MSFTNGP14.phx.gbl...
Is there a way to return multiple values from a function without using an
array? Would a dictionary object work better?

--
Roland Hall


s = Func()
Response.Write(s)

Function Func()
Const A = "a"
Const B = "b"
Const C = "c"
Func = A & "," & B & "," & C
End Function

Or do you consider a CSV string an array?

Whether a Dcitionary would be "better" depends on what are you trying to
do...
Jul 22 '05 #2

P: n/a
Roland Hall schrieb:
Is there a way to return multiple values from a function without using an
array? Would a dictionary object work better?


There is a third alternative: Make your own "datatype" by defining a class
that has all values you need:

Class MyClass
Public Value1
Public Value2
Public Value3
End Class

Function ReturnMyClass
Dim c
set ReturnMyClass = new MyClass
ReturnMyClass.Vlalue1 = "1"
ReturnMyClass.Vlalue2 = "2"
End Function

Jan
Jul 22 '05 #3

P: n/a
"McKirahan" wrote in message news:0Z********************@comcast.com...
: "Roland Hall" <nobody@nowhere> wrote in message
: news:uJ*************@TK2MSFTNGP14.phx.gbl...
: > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
: >
: > --
: > Roland Hall
:
: s = Func()
: Response.Write(s)
:
: Function Func()
: Const A = "a"
: Const B = "b"
: Const C = "c"
: Func = A & "," & B & "," & C
: End Function
:
: Or do you consider a CSV string an array?
:
: Whether a Dcitionary would be "better" depends on what are you trying to
: do...

Thank you for your suggestion.

If I returned my values as a string, then I'd have to parse it after my
call.
My question was kind of vague. I was trying to pass two return values
without having to do it with an array and I didn't want to make 2 calls to
the function or call 2 functions. I actually wanted named pairs. this=
some value, that= some value

I normally use functions as: result = myFunc(param1, param2, ...)
So, I can pass multiple parameters to the function but I was only receiving
one result. I have a need for two and possibly more in the future.

My function calls 4 other functions that do return arrays and at points I
have quite a few arrays in memory.

I first looked using a dictionary object but I can't make it work. It
appears either it is not possible or it's me. I saw in VB 6 I could return
the whole dictionary object but in vbscript, it appears I can only return
keys or items but not both. In VB 6, 'set' is used on the return. ASP
(vbscript) bit the dust when I tried that.

Ex.

function myFunc(param1, param2)
' create dictionary object
dim d
set d = CreateObject(...)
d.Add "string", value
...
set myFunc = d
end function

Now, myFunc = d.Keys or myFunc = d.Items works fine but I need the key and
item values or I have to index them.
So, I started reading about classes and that appears to be the right
approach. I'm just going to have more reading to do.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #4

P: n/a
"Jan Peter Stotz" wrote in message
news:1m*******************************@40tude.net. ..
: Roland Hall schrieb:
:
: > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
:
: There is a third alternative: Make your own "datatype" by defining a class
: that has all values you need:
:
: Class MyClass
: Public Value1
: Public Value2
: Public Value3
: End Class
:
: Function ReturnMyClass
: Dim c
: set ReturnMyClass = new MyClass
: ReturnMyClass.Vlalue1 = "1"
: ReturnMyClass.Vlalue2 = "2"
: End Function

Jan...

Thank you for your response. I started reading about classes today and it
appears this is the right approach for this application. It's just new to
me and will require some research to implement it. This helps.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #5

P: n/a
"Roland Hall" <nobody@nowhere> wrote in message
news:#p**************@TK2MSFTNGP15.phx.gbl...
"McKirahan" wrote in message news:0Z********************@comcast.com...
: "Roland Hall" <nobody@nowhere> wrote in message
: news:uJ*************@TK2MSFTNGP14.phx.gbl...
: > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
: >
: > --
: > Roland Hall
:
: s = Func()
: Response.Write(s)
:
: Function Func()
: Const A = "a"
: Const B = "b"
: Const C = "c"
: Func = A & "," & B & "," & C
: End Function
:
: Or do you consider a CSV string an array?
:
: Whether a Dcitionary would be "better" depends on what are you trying to
: do...

Thank you for your suggestion.

If I returned my values as a string, then I'd have to parse it after my
call.
My question was kind of vague. I was trying to pass two return values
without having to do it with an array and I didn't want to make 2 calls to
the function or call 2 functions. I actually wanted named pairs. this=
some value, that= some value

I normally use functions as: result = myFunc(param1, param2, ...)
So, I can pass multiple parameters to the function but I was only receiving one result. I have a need for two and possibly more in the future.

My function calls 4 other functions that do return arrays and at points I
have quite a few arrays in memory.

I first looked using a dictionary object but I can't make it work. It
appears either it is not possible or it's me. I saw in VB 6 I could return the whole dictionary object but in vbscript, it appears I can only return
keys or items but not both. In VB 6, 'set' is used on the return. ASP
(vbscript) bit the dust when I tried that.

Ex.

function myFunc(param1, param2)
' create dictionary object
dim d
set d = CreateObject(...)
d.Add "string", value
...
set myFunc = d
end function

Now, myFunc = d.Keys or myFunc = d.Items works fine but I need the key and
item values or I have to index them.
So, I started reading about classes and that appears to be the right
approach. I'm just going to have more reading to do.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

To extend your thoughts...

Declare the dictionary outside of all functions (globally) then add to the
Dictionary by assigning the name=value pair to the Item and make the Key
something that you'll reference later; (such as "a", "b", etc.)

' create dictionary object
Dim d
Set d = CreateObject("Scripting.Dictionary")
Call myFunc(param1, param2)
Set d = Nothing

function myFunc(param1, param2)
d.Add "a","string1=" & value1
d.Add "b","string2=" & value2
...
set myFunc = d
end function
Jul 22 '05 #6

P: n/a
"McKirahan" wrote in message news:Ye********************@comcast.com...

: Declare the dictionary outside of all functions (globally) then add to the
: Dictionary by assigning the name=value pair to the Item and make the Key
: something that you'll reference later; (such as "a", "b", etc.)
:
: ' create dictionary object
: Dim d
: Set d = CreateObject("Scripting.Dictionary")
: Call myFunc(param1, param2)
: Set d = Nothing
:
: function myFunc(param1, param2)
: d.Add "a","string1=" & value1
: d.Add "b","string2=" & value2
: ...
: set myFunc = d
: end function

I think this is the problem I had with the Dictionary object:

"set" myFunc = d

Usually it's just myFunc = d
Also, once you set d = nothing, the dictionary object is gone.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #7

P: n/a
"Roland Hall" <nobody@nowhere> wrote in message
news:#i**************@TK2MSFTNGP15.phx.gbl...
"McKirahan" wrote in message news:Ye********************@comcast.com...

: Declare the dictionary outside of all functions (globally) then add to the : Dictionary by assigning the name=value pair to the Item and make the Key
: something that you'll reference later; (such as "a", "b", etc.)
:
: ' create dictionary object
: Dim d
: Set d = CreateObject("Scripting.Dictionary")
: Call myFunc(param1, param2)
: Set d = Nothing
:
: function myFunc(param1, param2)
: d.Add "a","string1=" & value1
: d.Add "b","string2=" & value2
: ...
: set myFunc = d
: end function

I think this is the problem I had with the Dictionary object:

"set" myFunc = d
I should have removed that line from ny code.
Usually it's just myFunc = d
Also, once you set d = nothing, the dictionary object is gone.
Yes, but I was setting to Nothing after it was no longer referenced (or so I
thought -- I don't know all your code).

--
Roland Hall

Jul 22 '05 #8

P: n/a
"McKirahan" wrote in message news:m-********************@comcast.com...
: "Roland Hall" <nobody@nowhere> wrote in message
: news:#i**************@TK2MSFTNGP15.phx.gbl...
: > "McKirahan" wrote in message news:Ye********************@comcast.com...
: >
: > : Declare the dictionary outside of all functions (globally) then add to
: the
: > : Dictionary by assigning the name=value pair to the Item and make the
Key
: > : something that you'll reference later; (such as "a", "b", etc.)
: > :
: > : ' create dictionary object
: > : Dim d
: > : Set d = CreateObject("Scripting.Dictionary")
: > : Call myFunc(param1, param2)
: > : Set d = Nothing
: > :
: > : function myFunc(param1, param2)
: > : d.Add "a","string1=" & value1
: > : d.Add "b","string2=" & value2
: > : ...
: > : set myFunc = d
: > : end function
: >
: > I think this is the problem I had with the Dictionary object:
: >
: > "set" myFunc = d
:
: I should have removed that line from ny code.
:
: > Usually it's just myFunc = d
: > Also, once you set d = nothing, the dictionary object is gone.
:
: Yes, but I was setting to Nothing after it was no longer referenced (or so
I
: thought -- I don't know all your code).

Ok, I see what you're getting at. I can access the keys and values outside
the function if it's public instead of private.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #9

P: n/a
"Jan Peter Stotz" wrote in message
news:1m*******************************@40tude.net. ..
: Roland Hall schrieb:
:
: > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
:
: There is a third alternative: Make your own "datatype" by defining a class
: that has all values you need:
:
: Class MyClass
: Public Value1
: Public Value2
: Public Value3
: End Class
:
: Function ReturnMyClass
: Dim c
: set ReturnMyClass = new MyClass
: ReturnMyClass.Vlalue1 = "1"
: ReturnMyClass.Vlalue2 = "2"
: End Function

Ok, it appears this is what you're referring to but I am still calling the
function twice or am I doing something wrong?

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True

class shipping
public m_ups
public m_freight
end class

function getXMLShipping()
set getXMLShipping = new shipping
getXMLShipping.m_ups = "1.00"
getXMLShipping.m_freight = "2.00"
end function

dim shipUPS, shipFreight
shipUPS = getXMLShipping.m_ups
shipFreight = getXMLShipping.m_freight

Response.Write "UPS: " & shipUPS & "<br />" & vbCrLf & "Freight: " &
shipFreight & vbCrLf
%>
Perhaps I need to provide more information as to what I have and my intended
goal.

I have a function.
getXMLShipping(custNum)

custNum is a value of a cookie.

I call this function to get the shipping information for products being
sold. When only accepting a single carrier, it worked well. Now that I am
adding additional carriers it needs to be altered above the alterations I am
doing converting all files to XML.

The function gets information by calling 3 other functions.

1. get the shopping cart items based on custNum
2. get the UPS rate chart which returns the chart of rates per zone
3. get the zone the customer zip code falls within

I then look at each item, determine the shipping carrier for that item and
add it to the appropriate total while calculating weight * quantity of
items.

For items shipped by UPS, I then take the total weight for that zone and
calculate it against the rate/ounce of that zone and then convert oz to lb
and round up to the next lb.

For items shipped by freight I call a function that is passed the zip code
and total weight and I am returned the freight cost.

Now comes my dilemma. I need to return from the function UPS shipping and
freight shipping. Because freight shipping is so expensive, I need them
separate so I can show UPS shipping costs and freight rather than a total.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #10

P: n/a
"Roland Hall" <nobody@nowhere> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...

[snip]
I first looked using a dictionary object but I can't make it work. It
appears either it is not possible or it's me. I saw in VB 6 I could return the whole dictionary object but in vbscript, it appears I can only return
keys or items but not both. In VB 6, 'set' is used on the return. ASP
(vbscript) bit the dust when I tried that.

Ex.

function myFunc(param1, param2)
' create dictionary object
dim d
set d = CreateObject(...)
d.Add "string", value
...
set myFunc = d
end function

Now, myFunc = d.Keys or myFunc = d.Items works fine but I need the key and
item values or I have to index them.
So, I started reading about classes and that appears to be the right
approach. I'm just going to have more reading to do.


Your function looks fine. I believe your problem was that you were
forgetting to use the SET statement when you assigned the return value of
the function to a variable. The following worked for me:

<%
Function myFunc(param1, param2)
' create dictionary object
Dim d
Set d = CreateObject("Scripting.Dictionary")
d.Add "A", "Apple"
d.Add "B", "Banana"
d.Add "C", "Carrot"
Set myFunc = d
End Function

Dim d
Set d = myFunc("param1","param2")
Response.Write d("A")
%>
Jul 22 '05 #11

P: n/a
"Chris Hohmann" wrote in message
news:el*************@TK2MSFTNGP09.phx.gbl...
: "Roland Hall" <nobody@nowhere> wrote in message
: news:%2****************@TK2MSFTNGP15.phx.gbl...
:
: [snip]
: > I first looked using a dictionary object but I can't make it work. It
: > appears either it is not possible or it's me. I saw in VB 6 I could
: return
: > the whole dictionary object but in vbscript, it appears I can only
return
: > keys or items but not both. In VB 6, 'set' is used on the return. ASP
: > (vbscript) bit the dust when I tried that.
: >
: > Ex.
: >
: > function myFunc(param1, param2)
: > ' create dictionary object
: > dim d
: > set d = CreateObject(...)
: > d.Add "string", value
: > ...
: > set myFunc = d
: > end function
: >
: > Now, myFunc = d.Keys or myFunc = d.Items works fine but I need the key
and
: > item values or I have to index them.
: > So, I started reading about classes and that appears to be the right
: > approach. I'm just going to have more reading to do.
:
: Your function looks fine. I believe your problem was that you were
: forgetting to use the SET statement when you assigned the return value of
: the function to a variable. The following worked for me:
:
: <%
: Function myFunc(param1, param2)
: ' create dictionary object
: Dim d
: Set d = CreateObject("Scripting.Dictionary")
: d.Add "A", "Apple"
: d.Add "B", "Banana"
: d.Add "C", "Carrot"
: Set myFunc = d
: End Function
:
: Dim d
: Set d = myFunc("param1","param2")
: Response.Write d("A")
: %>

Oh, set outside the function. I didn't think of that. Makes sense, since
it is an object. Doh!
Thanks Chris. I'll try that.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #12

P: n/a
Roland Hall wrote:
Is there a way to return multiple values from a function without using an
array? Would a dictionary object work better?

You can return multiple arguments in a function's parameter list, since
function arguments are call-by-reference by default . So, for example,

' the call...
Dim strA, strB, strC, s
IF ( Func(strA, strB, strC) = 0 )then
Response.Write(s, strA, strB, strC)
....

' The called function...
Function Func(A, B, C)
A = "a"
B = "b"
C = "c"
Func = 0
End Function
Jul 22 '05 #13

P: n/a
"Michael D. Kersey" wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
: Roland Hall wrote:
: > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
: >
: You can return multiple arguments in a function's parameter list, since
: function arguments are call-by-reference by default . So, for example,
:
: ' the call...
: Dim strA, strB, strC, s
: IF ( Func(strA, strB, strC) = 0 )then
: Response.Write(s, strA, strB, strC)
: ...
:
: ' The called function...
: Function Func(A, B, C)
: A = "a"
: B = "b"
: C = "c"
: Func = 0
: End Function

I have the dictionary solution working but what if I'm passing different
variables than I'm returning?

Your timing was almost perfect. It answered another question of something I
worked around but didn't understand why it was happening.

I'll see if I can give an example...

dim gVar, result
gVar = "abcde"

function test(pVar)
pVar = left(pVar,3)
Response.Write gVar ' returns abc
test = pVar
end function

result = test(gVar)

It appears that since it is passed byRef, the original is changed when I
change what I thought was a private variable. If I change it to this:

function test(byVal pVar)
pVar = left(pVar,3)
Response.Write gVar ' returns abc
test = pVar
end function

gVar is no longer modified when I change pVar. It makes sense but I've
never experienced this issue before and should have on this very function,
although now what I used as an example here.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 22 '05 #14

P: n/a
Roland Hall schrieb:
Ok, it appears this is what you're referring to but I am still calling the
function twice or am I doing something wrong?


Yes, you are calling the function twice. Call it once and save the object
for future use:

dim ship
set ship = getXMLShipping

Response.Write "UPS: " & ship.m_ups & "<br />" & vbCrLf & "Freight: " & _
ship.m_freight & vbCrLf

Jan
Jul 22 '05 #15

P: n/a
"Jan Peter Stotz" <jp*****@gmx.de> wrote in message
news:8n******************************@40tude.net.. .
: Roland Hall schrieb:
:
: > Ok, it appears this is what you're referring to but I am still calling
the
: > function twice or am I doing something wrong?
:
: Yes, you are calling the function twice. Call it once and save the object
: for future use:
:
: dim ship
: set ship = getXMLShipping
:
: Response.Write "UPS: " & ship.m_ups & "<br />" & vbCrLf & "Freight: " & _
: ship.m_freight & vbCrLf

Thanks Jan.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #16

P: n/a
Roland Hall wrote:
"Michael D. Kersey" wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
: Roland Hall wrote:
: > Is there a way to return multiple values from a function without using
an
: > array? Would a dictionary object work better?
: >
: You can return multiple arguments in a function's parameter list, since
: function arguments are call-by-reference by default . So, for example,
:
: ' the call...
: Dim strA, strB, strC, s
: IF ( Func(strA, strB, strC) = 0 )then
: Response.Write(s, strA, strB, strC)
: ...
:
: ' The called function...
: Function Func(A, B, C)
: A = "a"
: B = "b"
: C = "c"
: Func = 0
: End Function

I have the dictionary solution working but what if I'm passing different
variables than I'm returning?
All variables in the parameter list are passed. When using the default
of call-by-refererence (ByRef), whether an argument is an input to the
function, an output of the function or both input/output depends on how
you code the function.

Suppose a values is _defined_ (not necessarily initialized) in the
calling program and passed as a ByRef argument to the
function/subroutine. The function/subroutine can return anything in that
argument. Above strA, strB, and StrC are not explicitly initialized by
the calling program; the called function sets them.
Your timing was almost perfect. It answered another question of something I
worked around but didn't understand why it was happening.

I'll see if I can give an example...

dim gVar, result
gVar = "abcde"

function test(pVar)
pVar = left(pVar,3)
Response.Write gVar ' returns abc
test = pVar
end function

result = test(gVar)

It appears that since it is passed byRef, the original is changed when I
change what I thought was a private variable. If I change it to this:

function test(byVal pVar)
pVar = left(pVar,3)
Response.Write gVar ' returns abc Should be pVar-----^^^^, gvar is still "abcde" test = pVar
end function

gVar is no longer modified when I change pVar. It makes sense but I've
never experienced this issue before and should have on this very function,
although now what I used as an example here.


As you note, when an argument is passed ByRef, changes made in the
called function/subroutine affect the passed variable in the calling code.

I usually think of calling ByRef as pushing a pointer to the variable
onto the stack and think of calling ByVal as pushing the contents of the
variable on the stack.

Defining function/subroutine arguments as ByVal can ensure that passed
variables are not modified inadvertently. But calling ByVal can be
significantly more costly: contrast passing ByVal a large structure
(e.g. an array, recordset, or dictionary object) where the entire
structure must be pushed onto the stack versus passing it ByRef, where
only a pointer to the array is pushed onto the stack.
Jul 22 '05 #17

P: n/a
"Michael D. Kersey" wrote in message
news:e8****************@TK2MSFTNGP10.phx.gbl...
: Roland Hall wrote:
: > Your timing was almost perfect. It answered another question of
something I
: > worked around but didn't understand why it was happening.
: >
: > I'll see if I can give an example...
: >
: > dim gVar, result
: > gVar = "abcde"
: >
: > function test(pVar)
: > pVar = left(pVar,3)
: > Response.Write gVar ' returns abc
: > test = pVar
: > end function
: >
: > result = test(gVar)
: >
: > It appears that since it is passed byRef, the original is changed when I
: > change what I thought was a private variable. If I change it to this:
: >
: > function test(byVal pVar)
: > pVar = left(pVar,3)
: > Response.Write gVar ' returns abc
: Should be pVar-----^^^^, gvar is still "abcde"

No, I mean gVar. When it was passed with byRef, by default, modifying the
length of pVar changed the length of gVar. I guess I never noticed it
before because I probably never modified the passed variable but rather
reassigned it to something else as:
gVar = "abcde"
function test(pVar)
dim npVar
npVar = left(pVar,3)
...
end function
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.