For Loop Return Value...

Fertil3

New member
Joined
Jan 4, 2008
Messages
2
Programming Experience
Beginner
Ok, I'm new to programming and just picked up VB .NET for my first language as I need to use it in school.

I have a For loop, with a set of conditional statements in it (2 sets of nested If Else checks), and all this is in a Function. The function should return a boolean value, but I'm not sure how to return a value from inside the If Else checks.

Example:

VB.NET:
Public Function Check(ByVal age As Integer, ByVal gender As String) As Boolean

Dim data As getData() ' returns an array of structrues...
Dim i As Integer
Dim maxValue As Integer = 5

For i = 1 To maxValue
  If data(i).age = age Then
    If data(i).gender = gender Then
      Return True ' this is the part i need help with...
    End If
  End If
Next

End Function

Not sure if that code helps any, but the function should return true if the age and gender passed into the function appears in the 'data' array of structures as a structure.

Any help would be awesome... I'm an utter noob and I can't seem to work out this scoping for crap! :confused:

Cheers in advance to anyone :)
 
You've already done it how it should be done. Return statement returns immediately, no code in method is executed after that.
 
Yeah, not only did I ask a question I should've been able to answer, but it was even totally the wrong part of the code causing the problem lol... thx for the response though.
 
Back
Top