View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default function call not returning changed value

Matilda,
Check the help for the difference between "ByVal" and "ByRef"
Hint: You're using the wrong one if you are changing the value of dStDt in
the function.

Or are you returning the date from the function ?
If so, you are not assigning a value to the return. There is no
startDateIs=SomeDate

NickHK

"Matilda" wrote in message
...
I'm sure this must be blindingly obvious to everyone but me, but ....

I have a userform with a list box for user to choose from a list of dates
which determines the start date of a range to be analysed.

My code is in a general module, so I have declared the two variables to

hold
the date and the list index globally, in the code general module.

The following is my code.

I can't for the life of me work out why the function correctly assigns the
date value to the list index, as displayed within the function, but on

return
to the code the variable is empty!!

aaarrrgghhh!!!


Many thanks for any help -

Matilda




public dStDt as date, iLstIndx as integer


sub mySub()

dStDt = startDateIs(dStDt)
msgbox dStDt ' display results of function on return

end sub



function startDateIs(byVal dStDt) as date


select case iLstIndx

case 0

' set value to dStDt

case 1

'set value to dStDt


etc...

end select

msgbox dStDt 'display results of function

end function