Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone explain this?

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
IE
I have a wrapper function for another function. In this case if you were to step through when you hit the line
test = True
then the equivalent statement
test = test(a_iArg1, 2, 3)
is also true, all good so far, continue to step through when the test() function returns to the wrapper the statement is now false. Why is this? I know by default if a function returns a boolean it is false and feel that it has something to do with that. Any ideas?


Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If (test(1)) Then
            Response.Write("true")
        Else
            Response.Write("false")
        End If
    End Sub

    Function test(ByVal a_iArg1) As Boolean
        test = test(a_iArg1, 2, 3)
    End Function

    Function test(ByVal a_iArg1, ByVal a_iArg2, ByVal a_iArg3) As Boolean
        test = True
    End Function
 
Try using this:
Code:
    Function test(ByVal a_iArg1) As Boolean
        Return test(a_iArg1, 2, 3)
    End Function

    Function test(ByVal a_iArg1, ByVal a_iArg2, ByVal a_iArg3) As Boolean
        Return True
    End Function

Not sure if that will fix it... but it might.

Senior Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top