View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_4_] Jim Thomlinson[_4_] is offline
external usenet poster
 
Posts: 1,119
Default Variable losing its value when calling new sub

You can pass variables as arguments...

Sub Test()
dim i as integer

i = 100
call DisplayI(i)
i = i + 50
call DisplayI(i)
end sub

sub DisplayI(byval i as Integer)
msgbox "The value of i is " & i
end sub
--
HTH...

Jim Thomlinson


"jim37055" wrote:


Is there any way to keep a value in a variable when I call a new sub?

I have a the same variable name in the new sub, and I want to carry
over the value that I had in the first sub which is where I set the
value of the variable.

I am sure there is an easy answer to this, but I am just trying to
learn as I go here..... I may be in over my head....


--
jim37055
------------------------------------------------------------------------
jim37055's Profile: http://www.excelforum.com/member.php...o&userid=27788
View this thread: http://www.excelforum.com/showthread...hreadid=473844