Re: How to get a value calculated in a Function by J-P-W
J-P-W
Thu Sep 07 17:15:42 CDT 2006
Bob Barrows [MVP] wrote:
> J-P-W wrote:
> > Peter wrote:
> >> "J-P-W" <jonpwebb@gmail.com> wrote in news:1157402638.015931.64040@
> >> 74g2000cwt.googlegroups.com:
> >>
> >>> Please can you tell me how to call the function 'run it' and find
> >>> out the value of 'TheMessage'
> >>
> >>
> >> Function runit()
> >> If condition Then
> >> runit = "Answer 1"
> >> Else
> >> runit = "Answer 2"
> >> End If
> >> End Function
> >>
> >> Response.Write runit
> >>
> >> =========================================
> >>
> >> If you intent to call this function several times with the same data
> >> being calculated each time, why not use a sub instead ?
> >
> > Thanks for the reply, I still couldn't get it to work!!! (I'd tried
> > this also)
>
> Please describe symptoms rather than the meaningless "doesn't work".
> Verify that you have followed the above example exactly. I.E., verify
> that you have assigned the value you wish the function to return to the
> name of the function.
> If you still can't get it to work, strip out everything that is not
> needed to demonstrate the problem and show us the exact code that
> "doesn't work". We need to be able to run the code ourselves, so "air"
> code that somewhat resembles your code will not do it. For example, the
> above example code cannot be run as-is. Here is a better example that
> will work if you place it in a blank asp page:
>
> <%
> response.write runit("A")
> function runit(parm)
> runit = "Answer " & parm
> end function
> %>
>
> This code works. I've just finished testing it. Try it out yourself and
> verify that it works. If it does not work, let us know and describe the
> symptoms. If it does work, check to see where the difference is in your
> code. If you can't figure out the difference, post the code.
>
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
Hi Bob,
Sorry that I didn't give a full run down, I was running late on
deploying the web page that needed this function, I really appreciate
the help I get from time to time on this group, from you and others,
this time I decided that I needed to quit learning and deploy!!! I've
acutally overwritten the failing function with the repetative code that
works fine!!!
I know I should know better.....
And yes your code worked fine, thanks, it must have been the way I
transposed my data into Peters example
Jon