Click here to Skip to main content
15,997,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I've got a warning with my groupTest Function
Function 'groupTEST' doesn't return a value on all code paths


How can I fix this?
I thought i have written a good if block
Here is my code:

VB
Function groupTest() As Object()

        If (My.User.IsInRole("RBAFCT_LIS")) Then

            Server.Transfer("adminpage.aspx")

        Else : Server.Transfer("userpage.aspx")

        End If

    Return

    End Function



Many thanks

Edit TR : Fixed language selection on error message and a couple of fussy grammer changes.
Posted
Updated 22-Apr-10 3:17am
v4

1 solution

What this means is that you're not actually returning anything (just Return just leaves the function).

If you intend to return something, do so. Otherwise, change the Function to a Sub:

VB
Sub groupTest()       
    If (My.User.IsInRole("RBAFCT_LIS")) Then
        Server.Transfer("adminpage.aspx")        
    Else : Server.Transfer("userpage.aspx")        
    End If
    Return 
End Sub


If you intend to return Nothing, do this:

VB
Function groupTest() As Object()        
    If (My.User.IsInRole("RBAFCT_LIS")) Then
        Server.Transfer("adminpage.aspx")        
    Else : Server.Transfer("userpage.aspx")        
    End If
    Return Nothing
End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900