ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDFs (https://www.excelbanter.com/excel-programming/333545-udfs.html)

DoctorG

UDFs
 
I apologize for the naive question but I cannot seem to find documentation
(even on McRitchie's) on how to create a User Defined Function with a return
value. Pls complete the following code...

Public Sub aaaaa

if itemcheck()=true then
msgbox("ok")
else
msgbox("not ok")
endif

Public function itemcheck

if blahblah=soso then
return_value=true
else
return_value=false
endif

end function

What do I have to add to the function so that it defines the return_value
and returns it to the calling subroutine;

Thanks for your patience


Stefi

UDFs
 
Public function itemcheck

if blahblah=soso then
itemcheck=true
else
itemcheck=false
endif

end function

Regards,
Stefi


€˛DoctorG€¯ ezt Ć*rta:

I apologize for the naive question but I cannot seem to find documentation
(even on McRitchie's) on how to create a User Defined Function with a return
value. Pls complete the following code...

Public Sub aaaaa

if itemcheck()=true then
msgbox("ok")
else
msgbox("not ok")
endif

Public function itemcheck

if blahblah=soso then
return_value=true
else
return_value=false
endif

end function

What do I have to add to the function so that it defines the return_value
and returns it to the calling subroutine;

Thanks for your patience


Bob Phillips[_7_]

UDFs
 
One of the not so nice things in VB (IMO). The function name is the return
value, so in your case you must add

itemcheck=return_value

or code it to set that inline.


--
HTH

Bob Phillips

"DoctorG" wrote in message
...
I apologize for the naive question but I cannot seem to find documentation
(even on McRitchie's) on how to create a User Defined Function with a

return
value. Pls complete the following code...

Public Sub aaaaa

if itemcheck()=true then
msgbox("ok")
else
msgbox("not ok")
endif

Public function itemcheck

if blahblah=soso then
return_value=true
else
return_value=false
endif

end function

What do I have to add to the function so that it defines the return_value
and returns it to the calling subroutine;

Thanks for your patience




DoctorG

UDFs
 
Thank you both!!


All times are GMT +1. The time now is 04:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com