<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Public Function does return SS in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665683#M33879</link>
    <description>Thanks for the clarificatin Norman. I was thinking in terms of "useful &lt;BR /&gt;
information", i.e. he was expecting something more specific.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
----&lt;BR /&gt;
Ed&lt;BR /&gt;
----</description>
    <pubDate>Tue, 06 Jun 2006 19:29:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-06-06T19:29:15Z</dc:date>
    <item>
      <title>Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665673#M33869</link>
      <description>The following code snippet is located within in my form level module in a cmd button click event.&lt;BR /&gt;
&lt;BR /&gt;
For i = 0 To lstOpenDwgs.ListCount - 1&lt;BR /&gt;
        Application.Documents.Item(lstOpenDwgs.List(i)).Activate&lt;BR /&gt;
        Set ssPlineCorrals = getPolyLineBlockCorrals()&lt;BR /&gt;
        MsgBox ssPlineCorrals.Count&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
The Public function getPolyLineBlockCorrals doesn't return the selection set to ssPlineCorrals variable.  The selection set is getting created but doesn't make back to the form code.&lt;BR /&gt;
What am I missing?&lt;BR /&gt;
&lt;BR /&gt;
Dim FilterType(0 To 2) As Integer&lt;BR /&gt;
    Dim FilterData(0 To 2) As Variant&lt;BR /&gt;
       &lt;BR /&gt;
    FilterType(0) = 8&lt;BR /&gt;
    FilterData(0) = "ContNum"&lt;BR /&gt;
    FilterType(1) = 0&lt;BR /&gt;
    FilterData(1) = "INSERT"&lt;BR /&gt;
    FilterType(2) = 2&lt;BR /&gt;
    FilterData(2) = "`*U*"&lt;BR /&gt;
' set an error trap for failed selection set calls&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set objSS = ThisDrawing.SelectionSets("test2corrals")&lt;BR /&gt;
    If Err = 0 Then&lt;BR /&gt;
            objSS.Clear&lt;BR /&gt;
        Else&lt;BR /&gt;
            Set objSS = ThisDrawing.SelectionSets.Add("test2corrals")&lt;BR /&gt;
    End If&lt;BR /&gt;
    objSS.Select acSelectionSetAll, , , FilterType, FilterData&lt;BR /&gt;
    objSS.Highlight True&lt;BR /&gt;
        &lt;BR /&gt;
    MsgBox objSS.Count ' test line&lt;BR /&gt;
       &lt;BR /&gt;
End Function</description>
      <pubDate>Tue, 06 Jun 2006 13:28:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665673#M33869</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2006-06-06T13:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665674#M33870</link>
      <description>Sorry this should have been called&lt;BR /&gt;
Public Function does NOT return SS</description>
      <pubDate>Tue, 06 Jun 2006 13:30:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665674#M33870</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2006-06-06T13:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665675#M33871</link>
      <description>Is your selection an AND or an OR for criteria?&lt;BR /&gt;
&lt;BR /&gt;
Also, is your function declared like this&lt;BR /&gt;
&lt;BR /&gt;
    Public Function getPolyLineBlockCorrals() As AcadSelectionSet&lt;BR /&gt;
        ..... 'whatever it does&lt;BR /&gt;
&lt;BR /&gt;
        Set getPolyLineBlockCorrals = objSS&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
Joe&lt;BR /&gt;
--&lt;BR /&gt;
&lt;BR /&gt;
&lt;HUTCH&gt; wrote in message news:5196898@discussion.autodesk.com...&lt;BR /&gt;
The following code snippet is located within in my form level module in a &lt;BR /&gt;
cmd button click event.&lt;BR /&gt;
&lt;BR /&gt;
For i = 0 To lstOpenDwgs.ListCount - 1&lt;BR /&gt;
        Application.Documents.Item(lstOpenDwgs.List(i)).Activate&lt;BR /&gt;
        Set ssPlineCorrals = getPolyLineBlockCorrals()&lt;BR /&gt;
        MsgBox ssPlineCorrals.Count&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
The Public function getPolyLineBlockCorrals doesn't return the selection set &lt;BR /&gt;
to ssPlineCorrals variable.  The selection set is getting created but &lt;BR /&gt;
doesn't make back to the form code.&lt;BR /&gt;
What am I missing?&lt;BR /&gt;
&lt;BR /&gt;
Dim FilterType(0 To 2) As Integer&lt;BR /&gt;
    Dim FilterData(0 To 2) As Variant&lt;BR /&gt;
&lt;BR /&gt;
    FilterType(0) = 8&lt;BR /&gt;
    FilterData(0) = "ContNum"&lt;BR /&gt;
    FilterType(1) = 0&lt;BR /&gt;
    FilterData(1) = "INSERT"&lt;BR /&gt;
    FilterType(2) = 2&lt;BR /&gt;
    FilterData(2) = "`*U*"&lt;BR /&gt;
' set an error trap for failed selection set calls&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set objSS = ThisDrawing.SelectionSets("test2corrals")&lt;BR /&gt;
    If Err = 0 Then&lt;BR /&gt;
            objSS.Clear&lt;BR /&gt;
        Else&lt;BR /&gt;
            Set objSS = ThisDrawing.SelectionSets.Add("test2corrals")&lt;BR /&gt;
    End If&lt;BR /&gt;
    objSS.Select acSelectionSetAll, , , FilterType, FilterData&lt;BR /&gt;
    objSS.Highlight True&lt;BR /&gt;
&lt;BR /&gt;
    MsgBox objSS.Count ' test line&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;/HUTCH&gt;</description>
      <pubDate>Tue, 06 Jun 2006 13:36:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665675#M33871</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-06T13:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665676#M33872</link>
      <description>thanks Joe... it appears that I didn't include...&lt;BR /&gt;
Set getPolyLineBlockCorrals = objSS&lt;BR /&gt;
&lt;BR /&gt;
It seems to work now... I am testing.</description>
      <pubDate>Tue, 06 Jun 2006 13:40:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665676#M33872</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2006-06-06T13:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665677#M33873</link>
      <description>Joe... is this the 'construct' that must be used if a function is meant to return a value?  That is that the same variable needs to be use? ... and like LISP it returns the last executed code to the calling function?</description>
      <pubDate>Tue, 06 Jun 2006 13:44:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665677#M33873</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2006-06-06T13:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665678#M33874</link>
      <description>If your function did not return a value it wouldn't be a function [but &lt;BR /&gt;
rather a sub].&lt;BR /&gt;
&lt;BR /&gt;
Yes, you have to use the construct as shown.&lt;BR /&gt;
&lt;BR /&gt;
[I don't know about AutoLISP, it's been about 10 years since I used it]. If &lt;BR /&gt;
memory serves me I think everything is a function in AutoLISP?&lt;BR /&gt;
&lt;BR /&gt;
Joe&lt;BR /&gt;
--&lt;BR /&gt;
&lt;BR /&gt;
&lt;HUTCH&gt; wrote in message news:5196940@discussion.autodesk.com...&lt;BR /&gt;
Joe... is this the 'construct' that must be used if a function is meant to &lt;BR /&gt;
return a value?  That is that the same variable needs to be use? ... and &lt;BR /&gt;
like LISP it returns the last executed code to the calling function?&lt;/HUTCH&gt;</description>
      <pubDate>Tue, 06 Jun 2006 13:50:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665678#M33874</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-06T13:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665679#M33875</link>
      <description>so putting it another way...&lt;BR /&gt;
Is it the fact that it is a 'function' ...&lt;BR /&gt;
or that the same varialbe is used, or&lt;BR /&gt;
that it is the last line in the function that makes for a successful return? ... or all of these?</description>
      <pubDate>Tue, 06 Jun 2006 13:53:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665679#M33875</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2006-06-06T13:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665680#M33876</link>
      <description>You have to use the construct I showed you, the way it is, because your &lt;BR /&gt;
returned variable is an object.&lt;BR /&gt;
&lt;BR /&gt;
Had you been returning say a String variable you would drop the Set.&lt;BR /&gt;
&lt;BR /&gt;
Either way you must state the function name equal to a variable or value of &lt;BR /&gt;
the datatype declared.&lt;BR /&gt;
&lt;BR /&gt;
Here are the two examples:&lt;BR /&gt;
&lt;BR /&gt;
Public Function WhatEver() As ObjectDataType&lt;BR /&gt;
    Set WhatEver = ObjectDataType variable&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Public Function WhatEver() As String&lt;BR /&gt;
    WhatEver = "Some string value or variable"&lt;BR /&gt;
        or&lt;BR /&gt;
    WhatEver = StringVariable&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
I'm should there are other examples that could be given but this should help &lt;BR /&gt;
explain the basics for your situation.&lt;BR /&gt;
&lt;BR /&gt;
Joe&lt;BR /&gt;
--&lt;BR /&gt;
&lt;BR /&gt;
&lt;HUTCH&gt; wrote in message news:5196948@discussion.autodesk.com...&lt;BR /&gt;
so putting it another way...&lt;BR /&gt;
Is it the fact that it is a 'function' ...&lt;BR /&gt;
or that the same varialbe is used, or&lt;BR /&gt;
that it is the last line in the function that makes for a successful return? &lt;BR /&gt;
... or all of these?&lt;/HUTCH&gt;</description>
      <pubDate>Tue, 06 Jun 2006 14:08:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665680#M33876</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-06T14:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665681#M33877</link>
      <description>No, vba does not work like lisp. A value is not automatically "returned". In &lt;BR /&gt;
lisp everything in parens is a function. In vba, to create a "function", you &lt;BR /&gt;
must assign a value or object to the procedure's name. Otherwise it remains &lt;BR /&gt;
just a "procedure" that performs some action.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
----&lt;BR /&gt;
Ed&lt;BR /&gt;
----</description>
      <pubDate>Tue, 06 Jun 2006 14:55:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665681#M33877</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-06T14:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665682#M33878</link>
      <description>Slight correction:&lt;BR /&gt;
&lt;BR /&gt;
In VB/VBA, a function DOES automatically return a value if you did not &lt;BR /&gt;
assign a value to the function within the function. The returned value, in &lt;BR /&gt;
this case, is the default value of the data type the function is supposed to &lt;BR /&gt;
return.&lt;BR /&gt;
&lt;BR /&gt;
For example,&lt;BR /&gt;
&lt;BR /&gt;
Public Function GetInteger() As Integer&lt;BR /&gt;
&lt;BR /&gt;
    Dim i as Integer&lt;BR /&gt;
    Dim j as Integer&lt;BR /&gt;
    i+j&lt;BR /&gt;
&lt;BR /&gt;
    ''Note, no value is assigned to GetInteger&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
This function returns 0, which is default value of Integer type&lt;BR /&gt;
&lt;BR /&gt;
You can even not specify Function's return type, like this:&lt;BR /&gt;
&lt;BR /&gt;
Public Function GetValue()&lt;BR /&gt;
&lt;BR /&gt;
    'Do something&lt;BR /&gt;
    'You can even not assign a value back to GetValue&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
In this case, it return Empty (vbEmpty, since there is VB enum. value to &lt;BR /&gt;
represent Empty, so we can still say the function returns a value), if you &lt;BR /&gt;
did not assign any value to the function, or it returns whatever data type &lt;BR /&gt;
you assign to the function&lt;BR /&gt;
&lt;BR /&gt;
Sometimes, VB/VBA simply does too much for programmers, that encourages "not &lt;BR /&gt;
so good practice". My thumb of rule here is to always expiciltly declare a &lt;BR /&gt;
function's return type and to always assign the function a return value &lt;BR /&gt;
within the function.&lt;BR /&gt;
&lt;BR /&gt;
"Ed Jobe" &lt;NOT.EDLJOBE&gt; wrote in message &lt;BR /&gt;
news:5197036@discussion.autodesk.com...&lt;BR /&gt;
No, vba does not work like lisp. A value is not automatically "returned". In&lt;BR /&gt;
lisp everything in parens is a function. In vba, to create a "function", you&lt;BR /&gt;
must assign a value or object to the procedure's name. Otherwise it remains&lt;BR /&gt;
just a "procedure" that performs some action.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
----&lt;BR /&gt;
Ed&lt;BR /&gt;
----&lt;/NOT.EDLJOBE&gt;</description>
      <pubDate>Tue, 06 Jun 2006 18:50:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665682#M33878</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-06T18:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Public Function does return SS</title>
      <link>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665683#M33879</link>
      <description>Thanks for the clarificatin Norman. I was thinking in terms of "useful &lt;BR /&gt;
information", i.e. he was expecting something more specific.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
----&lt;BR /&gt;
Ed&lt;BR /&gt;
----</description>
      <pubDate>Tue, 06 Jun 2006 19:29:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/public-function-does-return-ss/m-p/1665683#M33879</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-06T19:29:15Z</dc:date>
    </item>
  </channel>
</rss>

