|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
return value, exit functionTo use it some condition should be true. So i give it an Init method of type boolean being new to dotnet not sure how to code it? Function Init() As Boolean If ConditionNotMet Then Exit Function <---would this leave the function before returning false? Return False Else .... Return True End If End Function or Function Init() As Boolean If ConditionNotMet Then Return False<---should you return value before leave the function? Exit Function Else .... Return True End If End Function also in VB6 the "return" syntax used to be Init = True am i correct in thinking it is now Return True I noticed i had used the old version somewhere and it still compiled...are the two interchangable? Thanks mark Am 25.04.2010 02:03, schrieb mp:
> If one has a class. It works like in VB6 (see below).> To use it some condition should be true. > So i give it an Init method of type boolean > being new to dotnet not sure how to code it? > Function Init() As Boolean > If ConditionNotMet Then > Exit Function <---would this leave the function before returning > false? > Return False Isn't reached.> Else It leaves the function returning False.> .... > Return True > End If > End Function > or > Function Init() As Boolean > If ConditionNotMet Then > Return False<---should you return value before leave the function? > Exit Function Isn't reached.> Else It still works old style but I recommend "Return value" because it's clearer> .... > Return True > End If > End Function > > also in VB6 the "return" syntax used to be > Init = True > am i correct in thinking it is now > Return True > > I noticed i had used the old version somewhere and it still compiled...are > the two interchangable? where and which value is returned. If the function is exited without a return statement, but either with the Exit Function statement or at End Function, the last value assigned to 'Init', which is still an invisible, local variable, is returned. If the return type is a value type, you don't get a compiler warning (VB 2008) if you don't return a value for all code pathes. Untrue with reference types. -- Armin Am 25.04.2010 02:03, schrieb mp:
> If one has a class. Yes, the function will be left returning 'False', because 'False' is the > To use it some condition should be true. > So i give it an Init method of type boolean > being new to dotnet not sure how to code it? > Function Init() As Boolean > If ConditionNotMet Then > Exit Function<---would this leave the function before returning > false? > Return False default value for the 'Boolean' type and no value is assigned to 'Init' before calling 'Exit Function'. > Function Init() As Boolean Return will leave the function automatically, there is no need to call > If ConditionNotMet Then > Return False<---should you return value before leave the function? > Exit Function 'Exit Function'. > also in VB6 the "return" syntax used to be .... if followed by 'Exit Function'...> Init = True > am i correct in thinking it is now Yes, although the VB6-style is still supported.> Return True > I noticed i had used the old version somewhere and it still compiled...are Yes.> the two interchangable? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thanks to Armin and Herfried
mark Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:uOCG84B5KHA.6052@TK2MSFTNGP02.phx.gbl... > Am 25.04.2010 02:03, schrieb mp: >> If one has a class. >> To use it some condition should be true. >> So i give it an Init method of type boolean >> being new to dotnet not sure how to code it? >> Function Init() As Boolean >> If ConditionNotMet Then >> Exit Function<---would this leave the function before returning >> false? >> Return False > > Yes, the function will be left returning 'False', because 'False' is the > default value for the 'Boolean' type and no value is assigned to 'Init' > before calling 'Exit Function'. > >> Function Init() As Boolean >> If ConditionNotMet Then >> Return False<---should you return value before leave the function? >> Exit Function > > Return will leave the function automatically, there is no need to call > 'Exit Function'. > >> also in VB6 the "return" syntax used to be >> Init = True > > ... if followed by 'Exit Function'... > >> am i correct in thinking it is now >> Return True > > Yes, although the VB6-style is still supported. > >> I noticed i had used the old version somewhere and it still >> compiled...are >> the two interchangable? > > Yes. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thanks to Armin, Herfried and you Mp for asking.
I found this thread interesting and informative! I too am coming from VB6 and was not 100% sure how the "exit function" and "return" statements interacted Show quoteHide quote :-) Saga "mp" <nospam@Thanks.com> wrote in message news:%23zs2FcK5KHA.5476@TK2MSFTNGP06.phx.gbl... > Thanks to Armin and Herfried > mark > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > news:uOCG84B5KHA.6052@TK2MSFTNGP02.phx.gbl... >> Am 25.04.2010 02:03, schrieb mp: >>> If one has a class. >>> To use it some condition should be true. >>> So i give it an Init method of type boolean >>> being new to dotnet not sure how to code it? >>> Function Init() As Boolean >>> If ConditionNotMet Then >>> Exit Function<---would this leave the function before returning >>> false? >>> Return False >> >> Yes, the function will be left returning 'False', because 'False' is the >> default value for the 'Boolean' type and no value is assigned to 'Init' >> before calling 'Exit Function'. >> >>> Function Init() As Boolean >>> If ConditionNotMet Then >>> Return False<---should you return value before leave the >>> function? >>> Exit Function >> >> Return will leave the function automatically, there is no need to call >> 'Exit Function'. >> >>> also in VB6 the "return" syntax used to be >>> Init = True >> >> ... if followed by 'Exit Function'... >> >>> am i correct in thinking it is now >>> Return True >> >> Yes, although the VB6-style is still supported. >> >>> I noticed i had used the old version somewhere and it still >>> compiled...are >>> the two interchangable? >> >> Yes. >> >> -- >> M S Herfried K. Wagner >> M V P <URL:http://dotnet.mvps.org/> >> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > >
Add inner control event.
send the class type as a parameter. simmulate real rowEnter on DataGridView object. Update command to update field signing certificate error... Sending messages between windows Setting Event Log Size setting Posting a form to webserver using vb.net ASP table background color FTP Server Passive Mode |
|||||||||||||||||||||||