passing result of funtion back to main program

# Thread: passing result of funtion back to main program

1. Senior Member
Join Date
Dec 1969
Posts
201

## passing result of funtion back to main program

Hi All,<BR><BR>I have a function that produces a result, and I can&#039;t figure out how to pass the result back to the main program that calls the function. I tried &#039;return&#039; but I get an error...<BR><BR>see code:<BR><BR>Dim userNumber, result<BR>If Request.Form("txtUserEntry") &#060;&#062; "" Then<BR> If isNumeric(Request.Form("txtUserEntry")) Then<BR> userNumber = Request.Form("txtUserEntry")<BR> result = ChallengeFunction(userNumber)<BR> Response.Write "The sum of the digits for the number "&userNumber&" is "&result<BR> Else<BR> Response.Write "Your entry must be a number!"<BR> End If<BR>End If<BR>&#039;------- End Display for previous entry<BR><BR>&#039;--------------------------------- ChallengeFunction Area ---------------------<BR>Function ChallengeFunction(numStr)<BR>dim digit, x, y, z, remainder,q<BR>result=0<BR>y=userNumber <BR>z=1<BR>do while y&#062;0<BR> q=y/2<BR> x = split(q,".")<BR> remainder = y - (2*x(0))<BR> If (remainder= 0) Then<BR> digit = CStr(0) & digit<BR> Else<BR> result=result+1<BR> digit = CStr(1) & digit<BR> End If<BR> y = x(0)<BR> if len(digit)&#062;8 then<BR> exit function<BR> end if<BR>loop <BR><BR>End Function<BR><BR>How can I do this?<BR><BR>TIA<BR>Bastien

2. Senior Member
Join Date
Dec 1969
Posts
973

## ChallengeFunction = result

Function ChallengeFunction(numStr)<BR>.....<BR><BR>Challeng eFunction = result<BR><BR>End Function<BR>

3. Senior Member
Join Date
Dec 1969
Posts
201

## thanks

.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•