Hi,

I have a function that looks up various values and then results in a
value to a variable:

Function ShouldItBeReferred

If Claim3Date <> "" Then
'Do stuff......

TheAnswer = "Yes"
Else
TheAnswer = "No"
End If

'and various other stuf.........

If TheAnswer = "Yes" Then
TheMessage = "Yes, for now." 'real messageto follow..
Else
TheMessage = "No, for now." 'real messageto follow..
End If

End Function

Elsewhere on the page, a number of times, I need to Call the Function
and find out the value of 'TheMessage' to display.

I've tried:

Call ShouldItBeReferred .......... nothing

DisplayMessage = ShouldItBeReferred ..........nothing

Please can you tell me how to call the function 'run it' and find out
the value of 'TheMessage'

Many thanks

Jon

Re: How to get a value calculated in a Function by Peter

Peter
Mon Sep 04 17:22:19 CDT 2006

"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 ?


Re: How to get a value calculated in a Function by ravichoudhari

ravichoudhari
Tue Sep 05 00:06:34 CDT 2006


J-P-W wrote:
> Hi,
>
> I have a function that looks up various values and then results in a
> value to a variable:
>
> Function ShouldItBeReferred
>
> If Claim3Date <> "" Then
> 'Do stuff......
>
> TheAnswer = "Yes"
> Else
> TheAnswer = "No"
> End If
>
> 'and various other stuf.........
>
> If TheAnswer = "Yes" Then
> TheMessage = "Yes, for now." 'real messageto follow..
> Else
> TheMessage = "No, for now." 'real messageto follow..
> End If
>
> End Function
>
> Elsewhere on the page, a number of times, I need to Call the Function
> and find out the value of 'TheMessage' to display.
>
> I've tried:
>
> Call ShouldItBeReferred .......... nothing
>
> DisplayMessage = ShouldItBeReferred ..........nothing
>
> Please can you tell me how to call the function 'run it' and find out
> the value of 'TheMessage'
>
> Many thanks
>
> Jon


for the function to return a string value it should be defined as

function ShouldItBeReferred( paraneters-here) as string
...........do something
end function

and in this function the function name is treated as a string variable
which is to be returned, so u need to assign the string values to this
ShouldItBeReferred, and it should be called as DisplayMessage =
ShouldItBeReferred(parameters-here), the DisplayMessage variable will
get the returned string value.


Re: How to get a value calculated in a Function by Anthony

Anthony
Tue Sep 05 05:09:42 CDT 2006


"ravichoudhari" <ravichoudhari@gmail.com> wrote in message
news:1157432794.531457.105530@m73g2000cwd.googlegroups.com...
>
> J-P-W wrote:
> > Hi,
> >
> > I have a function that looks up various values and then results in a
> > value to a variable:
> >
> > Function ShouldItBeReferred
> >
> > If Claim3Date <> "" Then
> > 'Do stuff......
> >
> > TheAnswer = "Yes"
> > Else
> > TheAnswer = "No"
> > End If
> >
> > 'and various other stuf.........
> >
> > If TheAnswer = "Yes" Then
> > TheMessage = "Yes, for now." 'real messageto follow..
> > Else
> > TheMessage = "No, for now." 'real messageto follow..
> > End If
> >
> > End Function
> >
> > Elsewhere on the page, a number of times, I need to Call the Function
> > and find out the value of 'TheMessage' to display.
> >
> > I've tried:
> >
> > Call ShouldItBeReferred .......... nothing
> >
> > DisplayMessage = ShouldItBeReferred ..........nothing
> >
> > Please can you tell me how to call the function 'run it' and find out
> > the value of 'TheMessage'
> >
> > Many thanks
> >
> > Jon
>
>
> for the function to return a string value it should be defined as
>
> function ShouldItBeReferred( paraneters-here) as string
> ...........do something
> end function
>

As String cannot be used in VBScript it applies to VB6 and VB.NET. All
values in VBScript are of a variant data type which can store various
different types as is needed.

> and in this function the function name is treated as a string variable
> which is to be returned, so u need to assign the string values to this
> ShouldItBeReferred, and it should be called as DisplayMessage =
> ShouldItBeReferred(parameters-here), the DisplayMessage variable will
> get the returned string value.
>



Re: How to get a value calculated in a Function by J-P-W

J-P-W
Tue Sep 05 13:30:23 CDT 2006


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)

I've just repeated the code within the function 4 times on the page -
sloppy I know, I'll come to it later!

Thanks

Jon


Re: How to get a value calculated in a Function by Bob

Bob
Tue Sep 05 13:56:13 CDT 2006

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.



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