Hi There Guys,
I'm trying to get my head around this issue, on a few of my functions i get a warning " 'functionDealWithHiddenFields' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."
Example function:
vb.net Code:
Function functionDealWithHiddenFields(ByVal HTML As String, ByVal numHiddenFields As Integer, ByVal X As Integer) Try 'For i As Integer = 0 To numHiddenFields '// The html source Dim sText = HTML '// The string we are searching for Dim sPattern As String = "(?<=<input type=""hidden"" class="").*?(?="".*?')" '// This is the regular expression Dim regex As New Regex(sPattern, RegexOptions.IgnoreCase Or RegexOptions.Singleline) '// The matches that we return are put in the matchcollection Dim regexMatches As MatchCollection = regex.Matches(sText) '// Return 'Return regexMatches(0).ToString 'MessageBox.Show("Hidden Field " & X & ": " & regexMatches(X).ToString) Return regexMatches(X).ToString Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Function
The functions still work correctly (as far as i can tell) what would i need to do to the above function to remedy that warning?
thanks for any info guys
Graham




Reply With Quote