The difference between a test function returning a value with return and returning a value with a function name

Source: Internet
Author: User

‘*************************************************************************
' * * Module name: Engineering 1-form1
' * * Description: Blue Phoenix design Mall bath Fire Phoenix-Guo Wei | Blue Phoenix-Magic Spirit | Guo Wei-icecept
' * * Created by: Shower Fire Phoenix-Guo Wei
' * * Date: October 19, 2015 21:53:17
' * * Modified by: Shower Fire Phoenix-Guo Wei
' * * Date:
' * * Description: qq:493405998 | \ Wang: icecept
' * * Version: V1.0.0 | Http://blog.sina.com.cn/icecept
‘*************************************************************************

Public Class Form1

Private Sub Form1_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load

CHECKRETURN1 () ' test result Return True after execution, exit subroutine directly, after statement does not execute

CHECKRETURN2 () ' test result CheckReturn2 = True after execution, continue execution of subsequent statements.

End Sub

' 1==return

Function CheckReturn1 () as Boolean

Return True

MsgBox ("I'm CheckReturn1, I'll do It") ' No execution '

End Function

' 2== function name

Function CheckReturn2 () as Boolean

CHECKRETURN2 = True

MsgBox ("I'm CheckReturn2, I'll do it") ' executed '

End Function

End Class

So it would be better to return the value with return. But for the strict programming, or the function name return value is better, because the function name return value, directly return to write a sentence Exit Function, face return does not have to write, write more cumbersome. Over time habit one but nurturance, it is not good to rectify.

The difference between a test function returning a value with return and returning a value with a function name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.